私信  •  关注

Gerd

Gerd 最近创建的主题
Gerd 最近回复了

区别在于:

CREATE USER 'bill'@'%' IDENTIFIED BY 'passpass';

CREATE USER 'bill'@'localhost' IDENTIFIED BY 'passpass';

检查一下:

mysql> select user,host from mysql.user;
+---------------+----------------------------+
| user          | host                       |
+---------------+----------------------------+
| bill          | %                          | <=== created by first
| root          | 127.0.0.1                  |
| root          | ::1                        |
| root          | localhost                  |
| bill          | localhost                  | <=== created by second
+---------------+----------------------------+

指挥部

mysql -u bill -p

隐式访问“bill”@“localhost”,而不是“bill”@“%”。

没有“bill”@“localhost”的权限

你得到错误:

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

解决问题:

CREATE USER 'bill'@'localhost' IDENTIFIED BY 'passpass';

grant all privileges on . to 'bill'@'localhost' with grant option;