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.

STEP 1:

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

#service mysqld stop.

STEP 2:

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.
STEP 3:

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.
STEP 4:

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.


STEP 5:

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’;

STEP 6:

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

OUTPUT:

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

No comments:

Step-by-step OpenLDAP Installation and Configuration on server

This tutorial describes how to install and configure an OpenLDAP server and also an OpenLDAP client. Step by Step Installation and Conf...