Monthly Archives: August 2012

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;