MySQL – Linux – RESTORE MySQL Server ROOT Password


In this tutorial I show you how to reset the root pasword for your mysql-server if you have either forgotten it or didnt ever know it. You need to be logged in as root on the server in order to change the root password of the mysql server. Firstly you need to stop the mysql service by issuing the command, “service mysqld stop”, then you can issue the next command of “mysqld_safe –skip-grant-tables”, this will then start the mysql server without checking the privileges and especially the password. Once you have done this you will need to open another terminal window, and simply issue the command “mysql”, this will log your straight into the server. Now, execute an update command to change the password of the root user, in the user tables of the mysql database. “update mysql.user set password=PASSWORD(‘password’) where User=’root’;”. Execute the command, it should then tell you that there have been rows affected. From this point you need to flush privileges…which I forgot to mention…Ooooops. Although as you can see from the video everything worked just fine. From this point on you can login as normal. Firstly you will be required to restart the mysqld service once again, because it is still running in mysqld_safe mode. Issue the command, “service mysqld restart” then you can login to mysql normally, providing a password and username if required.



  1. When I type that command….

    # mysqld_safe –skip-grant-tables

    I get that message… How I fix it?

    150924 14:01:12 mysqld_safe Can't log to error log and syslog at the same time. Remove all –log-error configuration options for –syslog to take effect.
    150924 14:01:12 mysqld_safe Logging to '/var/log/mysql/error.log'.
    150924 14:01:12 mysqld_safe A mysqld process already exists

  2. hello please help me i install kali linux on wrong way . and i cant use kali linux terminal others working . by accident in istalling time i write my login password . i dont write roo and root password

  3. Thanks mate, I had problems with remotely installation of MySQL because the password set at the begining was in a weird "wizard" mode and it ended up in something else that I typed, then thanks to You I realised I need a full MySQL wipe also with user databases that aren't normally removed using –purge. After full removal I skipped that wizard setup and used secure installation and all went smooth and nice, even with remotely connect 😉

  4. tttthannnnksssssss from Brasil Guy !!!

    was not updat mysql.user set password=PASSWORD("password1")  where User'root'; in my .mysql_history I added manually   hehehe


Please enter your comment!
Please enter your name here