Solve the problem of resetting Mysql root user account password

  • 2021-12-12 06:03:30
  • OfStack

Problem description:

The following error appears when executing a command using mysqladmin. exe:


mysqladmin: connect to server at 'localhost' failed error: 'Access denied for user 'root'@'localhost' (using password: YES)'

Solution

Reset the mysql root user password as follows


# service mysqld stop
#  Enter mysql Installation directory /bin Directory ( If the relevant environment variables are not configured, the following operations are to enter this directory before executing ) To do the following 
# mysqld_safe --skip-grant-tables #  Start mysql

In addition, create a new console and execute the following command


# mysql -uroot -p  Enter mysql Console 
> use mysql;
> update user set password=password("123456") where user="root"; # Change root Password is 123456
> flush privileges; 
> quit
# service mysqld restart
# mysql -uroot  - p123456 # Login  

Attachment: linux xampp integrated environment mysql root password reset method

1. Stop the mysql server

sudo /opt/lampp/lampp stopmysql

2. Start mysqld with the `--skip-grant-tables 'parameter

sudo /opt/lampp/sbin/mysqld --skip-grant-tables 

3. Create another shell terminal and execute the following command


sudo /opt/lampp/bin/mysql  - uroot #  After the command is executed, it will directly enter mysql Command console 

4. Connect to mysql Permission Database

use mysql; 

5. Modify root user password


update user set password=password("123456") where user="root"; 

Note: Here, 123456 is the new password to be set for root users

6. Refresh the permission table

flush privileges; 

7. Exit mysql

quit;

8. Restart mysql service

sudo /opt/lampp/lampp startmysql 

9. Restart XAMPP

/opt/lampp/./lampp restart

Summarize

The above is this site to you to solve the problem of resetting Mysql root user account password, I hope to help you, if you have any questions welcome to leave me a message, this site will reply to you in time 1


Related articles: