[英]How can I make some tables read-only but allow users to create new ones?
I'm working on some data project with a few other collaborators. 我正在与其他一些合作者一起进行一些数据项目。 Most are fairly new to SQL so have inquired if I can make the 'raw' data tables read-only so they aren't accidentally altered, how would I go about doing that?
大多数都对SQL来说是相当陌生的,因此询问我是否可以将“原始”数据表设置为只读,以免意外更改它们,我该怎么做? Currently all users have
GRANT SELECT ON mydb.* TO 'user'@'%'
permissions, but I need to be a little more open. 当前,所有用户都具有
GRANT SELECT ON mydb.* TO 'user'@'%'
权限的GRANT SELECT ON mydb.* TO 'user'@'%'
,但我需要更加开放。
There's a question about making a single table read-only , but it seems like it would deny users the ability to make other tables; 关于将单个表设为只读存在一个问题,但似乎它会拒绝用户创建其他表的功能。 or if they did, they couldn't do anything with them.
否则,他们将无能为力。 There doesn't seem to be (or I can't find) a 'deny' setting like in NTFS that overrides allow/GRANT;
似乎没有(或我找不到)像NTFS中那样的“拒绝”设置会覆盖allow / GRANT; from what I read REVOKE is only the opposite of a prior GRANT, you can't "nest" them.
根据我的阅读,REVOKE与先前的GRANT相反,您不能“嵌套”它们。
I was considering making a separate 'raw' database that would be SELECT-only so users could copy it into the 'workspace' database, but that seems a bit hacky and will eat up some semi-significant amount of space on my budget cloud server. 我当时正在考虑制作一个单独的“原始”数据库,该数据库只能进行SELECT操作,以便用户可以将其复制到“工作区”数据库中,但这似乎有点骇人听闻,并且会占用我的预算云服务器上一些半大量的空间。 What's the proper solution?
什么是正确的解决方案?
GRANT SELECT ON example.* to 'someuser'@'somehost';
Give read only privilege. 授予只读特权。
GRANT CREATE ON example TO 'someuser'@'somehost';
Give create table privilege. 授予创建表特权。
You can make a single MyISAM table read only by compressing the table. 您可以通过压缩表使单个MyISAM表只读。 Use
myisampack
on the command line to pack the table. 在命令行上使用
myisampack
打包表。
More info can be found in the MySQL Manual: http://dev.mysql.com/doc/refman/5.0/en/myisampack.html 可以在MySQL手册中找到更多信息: http : //dev.mysql.com/doc/refman/5.0/en/myisampack.html
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.