Ubuntu: Change or Reset the MySQL Root Password CodeUnit 04 NOV 2010

MySQL gets installed with a default root account under the username “root”. Sometimes the system will allow you to install a root account without a password (VERY not safe), but for the most part you have to set a password on install.

If of course you are anything like me, you instantly forget this password and a month down the line when you come back to do some more tinkering, you’ll quickly realize that you need to change the damn password – and this is one way you could go about doing it!

First, stop the MySQL server by entering the following into a terminal:

sudo /etc/init.d/mysql stop

Next, start a custom mysqld configuration by skipping the password tables:

sudo mysqld –skip-grant-tables &

The next step is then to login as root:

mysql -u root mysql

Finally, replace the existing password with your new one and Bob’s your uncle!


Done. Oh, and don’t forget to restart the service with sudo /etc/init.d/mysql start if necessary.

(Ubuntu 10.10 Maverick Meerkat)

Related Posts:

About Craig Lotter

South African software architect and developer at Touchwork. Husband to a cupcake baker and father to two little girls. I don't have time for myself any more.