Article directory
一、Access denied for user ‘root’@‘localhost’
Access Denied
How to handle it,
1. Enter the following file
vim /etc/my.cnf
Addskip-grant-tables
under [mysqld] and save
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
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;