Linux server mysql connection problem record


一、Access denied for user ‘root’@‘localhost’

Access Denied
Insert image description here
How to handle it,

1. Enter the following file

vim /etc/my.cnf
Addskip-grant-tables under [mysqld] and save

Insert image description here

2. Restart mysql

  • Can be turned off and then on
systemctl stop mysql
systemctl start mysql
  • Restart
systemctl restart mysql

2. Forgot password and cannot log in

Approach,

1. Enter the following file

vim /etc/my.cnf
Add and modify under [client] password = 密码, save, and log in again with the set password
Insert image description here

3. Change password

You can use the following command to change the password

mysql -u root

update mysql.user set authentication_string=PASSWORD('123456') where User='root'; 
flush privileges; 

You still need to refresh your password once

set password for root@localhost = password('123456'); 
flush privileges; 


Summarize

如有启发,可点赞收藏哟~

Guess you like

Origin blog.csdn.net/weiCong_Ling/article/details/134890371