专注业务连续性支持与数据保护
« »
2014年5月2日技术合集

MySQL任意主机用户无法登录

在创建MySQL用户时,选择登录主机为“%”,意思为所有主机均可以连接。

命令如下:
grant all privileges on *.* to ‘kevin’@’%’ identified by ‘password’ with grant option;

创建完成后,登录发现提示如下错误:
ERROR 1045 (28000): Access denied for user ‘kevin’@’localhost’ (using password: YES)

从逻辑上说,%代表所有主机,为什么使用“localhost”就是不行呢?或者也有一种可能性,“%”不包括“localhost”主机,而创建连接时使用到了“localhost”。

新增用户@localhost:
grant all privileges on *.* to ‘kevin’@’localhost’ identified by ‘password’ with grant option;

刷新权限,登录成功。
flush privileges;

日志信息 »

该日志于2014-05-02 14:13由 kevin 发表在技术合集分类下, 评论已关闭。

评论已关闭。