MySQL - How to reset a forgotten Root password

I'm sure that we have all done it. Yep, that's right you've forgotten the MySQL root password. Fear not my fellow conrade, with a few simple simple commands you will be back in control.

Stop MySQL

First of all stop MySQL.

/etc/init.d/mysqld stop

Connect to MySQL

Next instruct MySQL to ignore the GRANT Tables. Then start MySQL.

mysqld_safe --skip-grant-tables 
mysql --user=root mysql

Reset Password

Next reset your password.

update user set Password=PASSWORD('new-password') where user='root';
flush privileges;

Start MySQL

Finally restart MySQL.

/etc/init.d/mysqld start

About the Author


R Donato

Rick Donato is the Founder and Chief Editor of He currently works as an SDN/NFV Solutions Architect and has a keen interest in automation and the cloud.

You can find Rick on Twitter @f3lix001