How to reset mysql root account password

        This article describes how to reset the MySQL root account password, you can follow the steps below:

1. Stop the MySQL service:

      Open a command prompt or terminal window and enter the following command to stop the MySQL service:

sudo systemctl stop mysql

2. Start the MySQL service and skip authorization authentication

     Enter the following command to skip authentication and start the MySQL service:

sudo mysqld_safe --skip-grant-tables &

 3. Log in to MySQL and update the root account password

        Enter the following command to log in to the MySQL server and update the root account password. Note that "new_password" in the following command should be replaced with the new password you want to set:

mysql -u root

UPDATE mysql.user SET authentication_string=PASSWORD('new_password') WHERE User='root';

FLUSH PRIVILEGES;

quit

4. Stop the MySQL service and restart it

      Enter the following commands to stop the MySQL service and restart it:

sudo systemctl stop mysql

sudo systemctl start mysql

5. Login with new password

      You should now be able to log into the MySQL server with the new password. It can be tested with the following command:

mysql -u root -p

        Enter the new password you just set to log in to the MySQL server.


New Era Migrant Workers

Guess you like

Origin blog.csdn.net/sg_knight/article/details/129875482