How to Create a Mysql Password for Root

John John (304)

If you've just installed MySQL, you will probably want to create a password for the root user.

If you'd like a fuller introduction, check out our introductory guide to PHP and MySQL.


Howchoo is reader-supported. As an Amazon Associate, we may earn a small affiliate commission at no cost to you when you buy through our links.

Simply type:

mysqladmin -u root password PASSWORD
where PASSWORD is the password you'd like to use.

Another example:

mysqladmin -u root password 5a0ZI73SU8xk
If you need to generate a password go to or use a password manager like 1Password.

John John (304)

If you're using MySQL, at some point you'll want to measure the size of your tables. This can help you identify issues, track table growth over time, estimate disk space requirements, etc.