mysql登录:access denied for user 'root'@'localhost'(using password:YES)

时间:2023-03-09 03:07:10
mysql登录:access denied for user 'root'@'localhost'(using password:YES)

mysql登录:

access denied for user 'root'@'localhost'(using password:YES)

解决:
use mysql;
select user,host from user;

+------+---------------+
| user | host |
+------+---------------+
| root | % |
| root | 127.0.0.1 |
| root | ::1 |
| | localhost |
| root | localhost | |
+------+---------------+

看到上面有user为空的记录,删掉它,重启mysql服务

 delete from user where user='';
flush privileges;
quit;

参考 http://holy2010.blog.51cto.com/1086044/684117