MySQL:创建新用户/尝试访问数据库
我的问题是: 我创建了一个新用户:将 sampdb.* 上的所有权限授予 'monty'@'' IDENTIFIED BY 'pass'
该用户出现在两个数据库中:mysql.user(完全没有权限)和mysql.db(几乎拥有除 GRANT 之外的所有权限)。好的。 之后,我尝试通过这个新用户访问 sampdb 数据库:mysql -u monty -ppass sampdb
。 MySQL 回答:“用户'monty'@'localhost(使用密码:YES)的访问被拒绝。
请告诉我,我哪里出错了?
My problem is:
I had created a new user:GRANT ALL PRIVILAGES ON sampdb.* TO 'monty'@'' IDENTIFIED BY 'pass'
This user had appiared in two databases: mysql.user(with no privilages at all) and mysql.db(with nearly all privilages except GRANT one). OK.
After that I tried to access the sampdb database by this new user:mysql -u monty -ppass sampdb
. MySQL answered: "Access denied for user 'monty'@'localhost (using password: YES)'.
Please, tell me, where did I mistake?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我认为您需要将权限授予
'monty'@'localhost'
,而不是'monty'@''
。目前,您正在尝试通过 localhost 进行连接,但'monty'@'localhost'
不存在。编辑:或
'monty'@'%'
,以允许来自任何主机的连接。I think you need to grant the privileges to
'monty'@'localhost'
, rather than'monty'@''
. At the moment, you're trying to connect via localhost, and'monty'@'localhost'
doesn't exist.edit: Or
'monty'@'%'
, to allow connections from any host.