Connect to MySQL Server without password in safe mode

This article contains information about mysql safe mode such as start mysql in safe mode, find mysqld_safe location, changing password.

MySQL Safe Mode

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

  • You forgot your password
  • The server is not responding properly
  • You get Access denied for user ‘xx’@’xxx’ (using password: YES)
  • 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

Find mysqld_safe location

To find the mysqld_safe location run the below command.

Start MySQL in Safe Mode

To start mysql in safe mode run the below command.

–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)

Start MySQL server

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

Give it a try in your development environment at first. Do not forget trying everything on development first.

You can find many more article about MySQL and many databases at dbtut. Use our navigation menu to reach every article you need or our search section on the upper right.

Mikael HOUNDEGNON
Author: Mikael HOUNDEGNON

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

Your email address will not be published. Required fields are marked *