Connect to MySQL Server without password in safe mode


Sometime you want to connect to your DB server without password because:

  • you forgot your password
  • the server is not responding properly
  • or you get Access denied for user ‘xx’@’xxx’ (using password: YES)
  • or the mysql.user table is corrupt
  • take the database offline for all client
  • many more …

In this article let assume we forgot our userID password ?  and would like to reset it.


Stop MySQL :


Get the location of mysqld_safe:


Start your MySQL instance in safe mode:


–skip-grant-tables: This option causes the server to start without using the privilege system at all, which gives anyone with access to the server unrestricted access to all databases

–skip-networking : This option will block TCP/IP Connection to MySQL except local connection.

This will be an ongoing command until the process is finished so open another shell/terminal window, log in without a password:


You don’t have to provide a password here, nice isn’t it!! ?

(replace xxx with your own userID and password)



Sart MySQL server and test it : 


Now you should be able to connect to root with your new password :


Give it a try in your development environment  ?


My name is Mikael HOUNDEGNON. I am an experienced MySQL DBA/Developer based in the greater Chicago area. You can find out more about me here. I blog here mostly about things I don’t want to forget ? most likely, MySQL Tips. My specialties : MySQL Replication (Master Slave, MultiMaster, Fail over, etc) MySQL Backups MySQL Query Optimization MySQL Performance Tuning MySQL Stored Procedures Storage Engine Tuning Do you have an interesting project idea? Or you just want to chat? Get in touch!

Leave a Reply