MySQL创建新用户时登录出错(ERROR 1045)
2015-11-02 14:37
816 查看
在MySQL中我用如下语句创建了一个新的用户
<span style="font-size:18px;">CREATE USER 'KevinYin'@'%' IDENTIFIED BY 'password'
GRANT ALL PRIVILEGES ON *.* TO 'KevinYin'@‘%'</span>
紧接着我用新创建的用户进行登录:
<span style="font-size:18px;">mysql -u KevinYin -p</span>mySQL报错,信息如下:
<span style="font-size:18px;">ERROR 1045 (28000): Access denied for user 'KevinYin'@'localhost' (using password: YES)</span>但是,我如果这样登录:
<span style="font-size:18px;">mysql -u KevinYin </span>即可正常登录
不清楚是什么造成这样的故障的,在网上找了一阵发现了原因:
“When multiple matches are possible, the server must determine which of them to use. It resolves this issue as follows: (...)
When a client attempts to connect, the server looks through the rows [of table mysql.user] in sorted order.
The server uses the first row that matches the client host name and user name.
(...) The server uses sorting rules that order rows with the most-specific Host values first. Literal host names [such as 'localhost'] and IP addresses are the most specific.”这是由系统中的匿名用户及MySQL的认证机制造成的。解决办法就是删除系统中的匿名用户:
DROP USER ''@'localhost'即可解决。
详情参考:MySQL ERROR 1045 (28000): Access denied for user 'bill'@'localhost'
(using password: YES)
<span style="font-size:18px;">CREATE USER 'KevinYin'@'%' IDENTIFIED BY 'password'
GRANT ALL PRIVILEGES ON *.* TO 'KevinYin'@‘%'</span>
<span style="font-size:18px;">FLUSH PRIVILEGES;</span>
紧接着我用新创建的用户进行登录:
<span style="font-size:18px;">mysql -u KevinYin -p</span>mySQL报错,信息如下:
<span style="font-size:18px;">ERROR 1045 (28000): Access denied for user 'KevinYin'@'localhost' (using password: YES)</span>但是,我如果这样登录:
<span style="font-size:18px;">mysql -u KevinYin </span>即可正常登录
不清楚是什么造成这样的故障的,在网上找了一阵发现了原因:
“When multiple matches are possible, the server must determine which of them to use. It resolves this issue as follows: (...)
When a client attempts to connect, the server looks through the rows [of table mysql.user] in sorted order.
The server uses the first row that matches the client host name and user name.
(...) The server uses sorting rules that order rows with the most-specific Host values first. Literal host names [such as 'localhost'] and IP addresses are the most specific.”这是由系统中的匿名用户及MySQL的认证机制造成的。解决办法就是删除系统中的匿名用户:
DROP USER ''@'localhost'即可解决。
详情参考:MySQL ERROR 1045 (28000): Access denied for user 'bill'@'localhost'
(using password: YES)
相关文章推荐
- MySQL中的integer 数据类型
- MySQL存储过程
- mysql中int、bigint、smallint 和 tinyint的区别与长度
- mysql load data 导出、导入 csv
- source命令执行SQL脚本文件
- MySQL创建用户及权限控制
- MySQL管理数据表
- linux下mysql添加用户
- mysql procedure
- mysql触发器
- MySQL 备份和恢复策略
- mac下安装mysql(转载)
- mysql 修改编码 Linux/Mac/Unix/通用(杜绝修改后无法启动的情况!)
- MySQL数据的导出、导入(mysql内部命令:mysqldump、mysql)
- mysql数据行转列
- Linux下修改MySQL编码的方法
- MySQL Server 日志
- MySQL 安全事宜
- MySQL 备份与恢复