How to reset MySQL root password in Linux console (SSH)

To reset MySQL root password you should log in as root to your Linux server, stop MySQL service, start it without password and permission checks, log in as root without authorization, update password and restart MySQL server. Now more info.

There are 6 steps:

  1. Log in as root (not sudo) to your Linux server
  2. Stop MySQL Service

service mysql stop


  1. Start MySQL in safe mode - without password and permission checks

mysqld_safe --skip-grant-tables &

If it's halted, press [Enter]


  1. Connect to MySQL as root without authorization:

mysql -u root mysql


  1. Set new password for root Run using Update statement and set privileges using FLUSH PRIVILEGES. Don’t' forget to write ";" in the end of each command.

UPDATE user SET password=PASSWORD('MY_NEW_PASSWORD') WHERE user='root';



  1. Restart the MySQL service.

service mysql restart


No Comments »

No comments yet.

RSS feed for comments on this post. TrackBack URL

Leave a comment Notes of web-specialist
Since 2009