MySQL 用户和所有权限
好的,我正在尝试将用户添加到 MySQL 数据库。该用户应该能够将其他用户添加到其拥有权限的数据库中。所以我这样做了:
GRANT ALL privileges ON thedbname.* TO 'topuser'@'%' IDENTIFIED BY 'pass';
但是,我这个用户无法添加用户。这是因为我只为单个数据库提供了“全部”吗?当我查看权限时,权限显示为“N”,而如果删除数据库名称,权限将显示为“Y”。
我希望“topuser”能够运行这个:
GRANT SELECT ON thedbname.* TO 'seconduser'@'%' IDENTIFIED BY 'pass';
他们不需要将用户添加到其他数据库,因此我在这里尝试。
这是一个 Web 应用程序,用户提供用户名和密码来访问数据库,这样密码就不会存储在代码中。欢迎其他解决方案!
Ok, I'm trying to add a user to a MySQL database. This user should be able to add other users to the database it has privileges for. So I did this:
GRANT ALL privileges ON thedbname.* TO 'topuser'@'%' IDENTIFIED BY 'pass';
However, I this user cannot add users. Is that because I only gave them 'all' for a single database? The permissions show up as 'N' when I view them whereas if I remove the database name they show as 'Y'.
I want 'topuser' to be able to run this:
GRANT SELECT ON thedbname.* TO 'seconduser'@'%' IDENTIFIED BY 'pass';
They do not need to add users to other databases, hence my attempts here.
This is for a web app where users provide a username and password to access a database so that a password is not stored in the code. Other solutions welcomed though!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您必须授予“授予其他特权”。 GRANT 手册可在此处获取。
MySQL 仅在 ALL 中包含基本权限,如果你仔细查看文档,它会说全部是:
所以你应该向你的顶级用户授予“授予选项”:
You have to GRANT the "grant to other privilege". The manual of the GRANT is available here.
MySQL to include only basic privileges in the ALL, if you take a close look at the documentation it says all is :
so you should grant the "grant option" to your top user :