How to reset MySQL password

If you have forgotten your MySQL password for root user and you want to login, the following steps would help you :

  • You have to stop the MySQL service in order to reset the password. You could do that by running the following command :
sudo /etc/init.d/mysql stop
  • The next is to start MySQL configuration :
sudo mysqld --skip-grant-tables &
  • Now login to mysql running the following command. You won’t be asked for password.
mysql -u root mysql
  •  After logging in, you get the mysql prompt, where you can update your password with the help of the following query :
UPDATE user SET Password=PASSWORD('your new password') 
WHERE User ='root'; FLUSH PRIVILEGES; exit;

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s