Mysql root用户无法本地登录

阅读更多
用root用户登录mysql,发现客户端工具可以正常连接,但在本地控制台却无法登录。
提示如下错误:
[root@admin05 bakmysql]# mysql -u root -p
Enter password: 
ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: YES)


在客户端查询mysql.user表发现:
SELECT USER,HOST,PASSWORD FROM USER WHERE USER='root';

发现,root用户只有“%”、“admin05”和“127.0.0.1”三条主机,并没有“localhost”的主机。手动添加后问题解决。

Database changed
mysql>  SELECT USER,HOST,PASSWORD FROM USER WHERE USER='root';
+------+-----------+-------------------------------------------+
| USER | HOST      | PASSWORD                                  |
+------+-----------+-------------------------------------------+
| root | %         | *49034D5239CD46EB55F11360A500C135B9BA40BC |
| root | admin05   | *49034D5239CD46EB55F11360A500C135B9BA40BC |
| root | 127.0.0.1 | *49034D5239CD46EB55F11360A500C135B9BA40BC |
| root | localhost | *49034D5239CD46EB55F11360A500C135B9BA40BC |
+------+-----------+-------------------------------------------+
4 rows in set (0.00 sec)

mysql>

你可能感兴趣的:(mysql,localhost,Access,denied)