mysql 5.6.41创建新用户碰到的问题

mysql -uroot -p

use mysql;

create user system@'%' identified by '密码';

grant all on *.* to system@'%' with grant option;

然后退出,重新使用system登陆,报错

ERROR 1045 (28000): Access denied for user 'xxx'@'localhost' (using password: YES)

错误原因:使用select  host,host from mysql.user;可以查看用户名和账户名,从这里可以发现

你有一个用户名为空的账户,mysql会先匹配它,然后就一直提示你密码错误,删掉这个匿名用户,然后执行 FLUSH PRIVILEGES;

删除语句:

Delete FROM user Where User='' and Host='localhost';
flush privileges;

重新利用system登陆即可

猜你喜欢

转载自www.cnblogs.com/dong3210/p/9634071.html
今日推荐