一旦工作,那就要努力的干,聪明的干,快速的干——用省下来的时间干自己喜欢干的事情。!

MySQL授权用户 ‘test’@’%’,却在localhost中不能登录。

数据库 lampnick 2303℃ 0评论

MySQL授权用户 'test'@'%',却在localhost中不能登录。

mysql -utest -h127.0.0.1 -p 或者mysql -utest -hlocalhost -p 

报如下错误

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

查看mysql数据库中的user表数据如下:

mysql> select host ,user from user where user='test';
 +-------------------------+---------------+
 | host                    | user          |
 +-------------------------+---------------+
 | %                       | test          |
 +-------------------------+---------------+
 8 rows in set (0.00 sec)

原来是因为%并不包括localhost。

解决方案:将需要将localhost加入到user表

grant all privileges on *.* to 'test'@'localhost' identified by 'test' with grant option;
flush privileges;

转载请注明:MitNick » MySQL授权用户 ‘test’@’%’,却在localhost中不能登录。

喜欢 (1)or分享 (0)
头像
发表我的评论
取消评论
表情

Hi,您需要填写昵称和邮箱!

  • 昵称 (必填)
  • 邮箱 (必填)
  • 网址