MySQL password is correct but can not log -1045 Access denied for user 'root' @ 'localhost' (using password locally: YES
MySQL password is correct but can not log on locally
Given as follows:
ERROR 1045 (28000): Access denied for user ‘root‘@‘localhost‘ (using password: YES)
Solution:
1, parameter start mysql added skip mode password problem, as follows:
vim /etc/my.cnf(www.xcjl0834.com)
Plus skip-grant-tables in [MySQL] below,
This used to skip the password problem, but this does not completely resolved.
2, restart the mysql service
I am using a Mysql Linux system, the statement is as follows:
Check the port number:
ps aux | grep mysqld
View status:
systemctl status mysqld
Restart mysql service
systemctl restart mysqld
Try to connect:
mysql -uroot -p123456(m.jlnk3659999.com)
Enter the password, just skip the password has been set that can be ignored
Steps are as follows:
[root@localhost ~]# mysql -uroot -p123456
mysql> use mysql
Database changed
mysql> select user,host,password from user where user='root';
+------+-----------------------+-------------------------------------------+
| user | host | password |
+------+-----------------------+-------------------------------------------+
| root | % | *00A51F3F48415C7D4E8908980D443C29C69B60C9 |
| root | localhost.localdomain | *00A51F3F48415C7D4E8908980D443C29C69B60C9 |
| root | 127.0.0.1 | *00A51F3F48415C7D4E8908980D443C29C69B60C9 |
| root | ::1 | *00A51F3F48415C7D4E8908980D443C29C69B60C9 |
+------+-----------------------+-------------------------------------------+
4 rows in set (0.02 sec)
mysql> update user set host='localhost' where user='root' and host='%';
Query OK, 1 row affected (0.01 sec)
Rows matched: 1 Changed: 1 Warnings: 0
mysql> flush privileges;
Query OK, 0 rows affected (0.03 sec)
mysql> quit
Bye
OK, quit mysql, mysql restart to solve the problem
Compare the before and after:
[root@localhost ~]# mysql -uroot -p
mysql> use mysql;
Database changed
mysql> select user,host,password from user where user='root';
+------+-----------------------+-------------------------------------------+
| user | host | password |
+------+-----------------------+-------------------------------------------+
| root | localhost | *00A51F3F48415C7D4E8908980D443C29C69B60C9 |
| root | localhost.localdomain | *00A51F3F48415C7D4E8908980D443C29C69B60C9 |
| root | 127.0.0.1 | *00A51F3F48415C7D4E8908980D443C29C69B60C9 |
| root | ::1 | *00A51F3F48415C7D4E8908980D443C29C69B60C9 |
+------+-----------------------+-------------------------------------------+
4 rows in set (0.00 sec)
mysql>
OK!(3g.xcjl0834.com)
The above is a small series to introduce the MySQL password is correct but can not log on locally -1045 Access denied for user '' root '' @ '' localhost '' (using password: YES, we want to help.