Saturday, 6 January 2018

How to reset Mysql Root Password

how to reset the forgotten Mysql database root password which doesn’t affect any databases.


First, We need to stop the service and process of Mysql running on the server.To do this, Use the command.

#service mysqld stop.


Now, We need to initiate MySQL process without asking any password using the command,

#mysqld_safe –skip-grant-tables &

When we run the above command, Mysql process will allow us to login to the MySQL server without any password.

Wait for few minutes and press Enter.

Now, It’s time to login to database as root user but without password,

#mysql -u root

You will be allowed to log in to the database.

Now, Let’s list the available databases.

mysql>show databases;

We have to choose mysql database for setting up the new password for root user.


Now, We have to set a new password for the root user using the below command.

mysql> update user set password=PASSWORD(“NEW_PASSWORD_HERE”) where User=’root’;


We have to execute the flush privileges command to update the changes to take effect.

mysql>flush privileges

Now exit from the mysql shell and restart mysql service Once and then try to login with your new mysql password.

#service mysqld restart


Now, You can be able to login to mysql with your new custom password.

No comments:

How to Download and Install RHEL8 Beta For Free (Red Hat Enterprise Linux)

RHEL (Red Hat Enterprise Linux) 8 beta was released on November 14, 2018, 4 years after the release of RHEL 7. This tutorial will be showi...