Engineer Jagat

IT & Engineering Stuff

How to reset the MySQL root password?

April 8, 2021
How to reset the MySQL root password?

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.

Let’s do Step-by-Step

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

  1. UPDATE mysql.user SET Password=PASSWORD(‘your password) WHERE User=’root’;
  2. exit;

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

If you want to set up a Web Server on Raspberry Pi, check this link “How to Setup Web Server on Raspberry Pi?

Buy Best Book to develop your SQL Skills

Share with Friends
Copyright © 2020-2021 Engineer Jagat All rights reserved. Developed by Ravindra Rana