MySQL is a Database Management System, it provides the interface to perform operations in a Database.
By default it has one User which is the root, it may be happened to forget the password of the root User. So with this trick, we could reset our password.
Step 1: Open Terminal or Connect using SSH
If we are resting in a live Server then we need to access the terminal using SSH, if we are in a local Server then just need to open the terminal and place this code.
sudo service mysqld stop
Step 2: Start MySQL in Safe Mode
sudo mysqld_safe –skip-grant-tables &
Step 3: Change Password
After sudo mysqld_safe –skip-grant-tables & command you will log in MySQL then update these commands
- UPDATE mysql.user SET Password=PASSWORD(‘your password) WHERE User=’root’;
- FLUSH PRIVILEGES
Step 4: Shutdown –skip-grant and Start Normal
After changing the password of root we have to shutdown –skip-grant and run or start as normal mode. To do that we need palace some commands which are:
sudo mysqladmin -u root -p shutdown
sudo service mysqld start