Recover MySQL root password

  • Posted on: 23 March 2013
  • By: Zhijun Chen

I forgot MySQL root password once so I put the steps here for future reference.

* Stop MySQL Service

  The first step is stopping MySQL Service.

  Under Linux/Ubuntu:

sudo /etc/init.d/mysql stop

  Under Mac:

sudo /usr/local/mysql/support-files/mysql.server stop
* Navigate to MySQL folder and start MySQL Server without password

mysqld_safe --skip-grant-tables &
* Connect to MySQL server

mysql -u root
* Update root user password

use mysql;
update user set pasword=PASSWORD(“new_password”) where user = 'root';
flush privileges;
* Restart MySQL server and login with new password

  Under Linux/Ubuntu:

sudo /etc/init.d/mysql restart

  Under Mac:

sudo /usr/local/mysql/support-files/mysql.server restart

  Login with new password

mysql -u root -p



Add new comment

Plain text

  • No HTML tags allowed.
  • Lines and paragraphs break automatically.
This question is for testing whether or not you are a human visitor and to prevent automated spam submissions.