less than 1 minute read

There are loads of ways to reset a forgotten MySQL root password. Here is my favourite method.

Log into the server

Elevate to root run the command below (the & is important):

service mysql stop

mysqld_safe –skip-grant-tables &

Press enter

Now type: mysql -uroot

Use the following statements to reset the password. As an example we will use the password changeme but you should choose something secure.

use mysql;

update user set password=PASSWORD("changeme") where User="root";

flush privileges;



Finally type

service mysql start

The password has been reset. Ensure you change it if you used the example above rather than setting your own.


Leave a comment