• Share on Tumblr
  • Sharebar

Once in a while you want to reset your mysql root password, here is how you can do it.

Stop the MySql service

sudo /etc/init.d/mysql stop

Restart MySql in safe mode and skip grant table so that you can login with root without any password.

sudo mysqld_safe --skip-grant-tables &

Login with root

mysql -u root

Connect to MySql database

use mysql;

Reset the password to a new password

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

Flush privileges for changes to take affect

flush privileges;

Exit from current MySql connection


Stop the MySql service running in safe mode

sudo /etc/init.d/mysql stop

Start MySql again

sudo /etc/init.d/mysql start

Login with your new password

mysql -u root -p

Tagged with:

2 Responses to Mysql – Resetting root password

  1. reeloo says:

    This is ok for MySQL server not accessible from network. Using “–skip-networking” is a more safe way when “–skip-grant-tables” is set.

  2. [...] How to reset MySql root password    Database Read the original post on DZone… [...]

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>