如何在MySQL中为用户授予特定权限?
我想允许用户从特定的表和视图中进行选择,并执行特定的过程。我写了这样一个脚本:
CREATE USER 'user'@'%' IDENTIFIED BY 'user';
GRANT SELECT ON
database.table1,
database.view1,
database.view2
'user'@'%' IDENTIFIED BY 'user'
WITH MAX_QUERIES_PER_HOUR 0 MAX_CONNECTIONS_PER_HOUR 0 MAX_UPDATES_PER_HOUR 0 MAX_USER_CONNECTIONS 0;
GRANT EXECUTE ON PROCEDURE
database.procedure1,
database.procedure2
'user'@'%' IDENTIFIED BY 'user'
WITH MAX_QUERIES_PER_HOUR 0 MAX_CONNECTIONS_PER_HOUR 0 MAX_UPDATES_PER_HOUR 0 MAX_USER_CONNECTIONS 0;
但是它不起作用。我做错了什么?
I'd like to allow user to SELECT from specific tables and views, and EXECUTE specific procedures. I've written such a script:
CREATE USER 'user'@'%' IDENTIFIED BY 'user';
GRANT SELECT ON
database.table1,
database.view1,
database.view2
'user'@'%' IDENTIFIED BY 'user'
WITH MAX_QUERIES_PER_HOUR 0 MAX_CONNECTIONS_PER_HOUR 0 MAX_UPDATES_PER_HOUR 0 MAX_USER_CONNECTIONS 0;
GRANT EXECUTE ON PROCEDURE
database.procedure1,
database.procedure2
'user'@'%' IDENTIFIED BY 'user'
WITH MAX_QUERIES_PER_HOUR 0 MAX_CONNECTIONS_PER_HOUR 0 MAX_UPDATES_PER_HOUR 0 MAX_USER_CONNECTIONS 0;
But it doesn't work. What am I doing wrong?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
尝试
(我不相信您在创建用户后需要 IDENTIFIED BY 部分)。 授予文档。
这应该是正确的语法。一旦您验证这对您有用,您就可以在一条语句中添加多个表/视图。
Try
(I don't beleive you need the IDENTIFIED BY portion after you create the user). Grant Doc.
This should be the correct syntax. You can add multiple tables/views in one statement once you verify this works for you.