First of all Stop the mysql service if its running

$service mysql stop

Then restart mysql with skip-grant-tables option, which will allow any user to login into mysql without asking for password.

$mysqld_safe –skip-grant-tables

Now login into mysql without password

$mysql –user=root mysql

You can now update the password of root user and flush priviledges.

mysql>update user set Password=PASSWORD(‘new-password’) where user=’root’;

mysql>flush privileges;


At last you have to stop mysqld and start mysql. For this you need to find the Process ID of mysqld services

$ps ax | grep mysqld

you get two process with name mysqld and mysqld_safe

Kill both the process with the

$kill -9 <mysqld process id>

$kill -9 <mysqld_safe process id>

Now Restart Mysql

$service mysql start


Reset Forgotten MySQL Root Password

Leave a Reply

Your email address will not be published.