Home Linux Lab: How To Reset MySQL 5.7 root user Password

Lab: How To Reset MySQL 5.7 root user Password

I forget the MySQL database root user password. Help me how can I fix it??

Reset MySQL 5.7 root user PasswordReset MySQL 5.7 root user Password

I am assuming that you have installed the MySQL 5.7 version and forget the MySQL root user password. Here I will help you to fix this situation. Both methods will work on CentOS or Ubuntu machines.

For Ubuntu Server

1.First need to stop the mysql server service

On Ubuntu Server,

# sudo service mysql stop

2. Now create the /var/run/mysqld directory.

# sudo mkdir -p /var/run/mysql
# sudo chown mysql:mysql /var/run/mysqld

3. Run the following command to login to mysql without root password:

# sudo /usr/sbin/mysqld --skip-grant-tables --skip-networking &
--skip-grant-tables command output
–skip-grant-tables command output

4. This command will let you login without any password using root user.

# mysql -u root

5. Run the following command to set new password:

# use mysql;
# UPDATE user set authentication_string=PASSWORD('Itsmearunchandel@123') WHERE User='root';
# flush privileges;
MySQL command to reset root user password
MySQL command to reset root user password

6. Now exit the mysql and start the mysql service. Try the new mysql root user password.

Login with new mysql root passwordLogin with new mysql root password

Recommended: Allow Remote Access to MySQL Database on Ubuntu


Congratulations !!!

You have successfully learned how to reset MySQL 5.7 root user password on ubuntu server.

 

LEAVE A REPLY

Please enter your comment!
Please enter your name here