How to reset MySQL 8.0 root password on Centos 7.x?

You may need to reset your MySQL root password if you lost or forget it. MySQL stores the existing password to the user table. To update the same password, we need to bypass the MySQL authentication. 

Please refer to the following steps to reset MySQL root password using -skip-grant-tables.

  1. Log in to your server using SSH.

  2. Stop the MySQL service using the below command.

    # systemctl stop mysqld.service
  3. Run the below command to bypass MySQL authentication.

    # mysqld --skip-grant-tables --user=mysql &
  4. Log in to MySQL now and it will not ask for the password.

    # mysql -u root
  5. Reload all the grants using the below commands.

  6. Run the below query to modify the root password. Ensure that you change the new_password with your updated password.

    # ALTER USER 'root'@'localhost' IDENTIFIED BY 'new_passowrd';
  7. Stop and start the MySQL service with the below command.

    # systemctl stop mysqld.service# systemctl start mysqld.service
  8. Now, check with the new password, and you should log in without any issue.

    # mysql -u root -p

Related Articles

How to Find All Files Owned by a Specific User in Unix/Linux?

You might receive an issue where you require to find all the files that are owned by a specific...

How to install MongoDB version 4.0 on Centos 7?

MongoDB is an open-source and free Database service. It is a NoSQL Database and it is different...

How To Install PIP in Linux?

PIP called a Package management system for Python. It allows your system to install and manage...

How To install Nginx on CentOS 7?

Nginx is a Web server that can be installed on Linux Server. You may have heard about Apache Web...

How to flush DNS cache on linux?

DNS is responsible for resolving website names into their respective IPs. Whenever you visit a...

  • 0 Users Found This Useful

Was this answer helpful?