首页
学习
活动
专区
工具
TVP
发布
社区首页 >问答首页 >MySql :是否授予只读选项?

MySql :是否授予只读选项?
EN

Stack Overflow用户
提问于 2013-11-18 05:42:25
回答 4查看 194.9K关注 0票数 122

我有一个用户,我想授予他对db架构的所有读权限。

一种方法是:

GRANT SELECT, SHOW_VIEW  ON test.* TO 'readuser'@'%';

有没有办法在授权中对所有读操作进行分组?

EN

回答 4

Stack Overflow用户

发布于 2013-11-18 15:16:54

GRANT SELECT ON *.* TO 'user'@'localhost' IDENTIFIED BY 'password';

这将创建一个拥有包括视图在内的所有数据库的SELECT权限的用户。

票数 18
EN

Stack Overflow用户

发布于 2016-08-12 18:50:50

您可以授予用户的各种权限包括

ALL PRIVILEGES- This would allow a MySQL user all access to a designated database (or if no database is selected, across the system)
CREATE- allows them to create new tables or databases
DROP- allows them to them to delete tables or databases
DELETE- allows them to delete rows from tables
INSERT- allows them to insert rows into tables
SELECT- allows them to use the Select command to read through databases
UPDATE- allow them to update table rows
GRANT OPTION- allows them to grant or remove other users' privileges

要为特定用户提供权限,您可以使用此框架:

GRANT [type of permission] ON [database name].[table name] TO ‘[username]’@'localhost’;

我发现this的文章很有帮助

票数 14
EN

Stack Overflow用户

发布于 2015-10-26 23:28:15

一步一步地指导我找到了here

为MySQL创建只读数据库用户帐户

在UNIX提示符处,运行MySQL命令行程序,然后通过键入以下命令以管理员身份登录:

mysql -u root -p

键入root帐户的密码。在mysql提示符下,执行以下步骤之一:

要授予用户从任何主机访问数据库的权限,请键入以下命令:

grant select on database_name.* to 'read-only_user_name'@'%' identified by 'password';

如果收集器将安装在与数据库相同的主机上,请键入以下命令:

grant select on database_name.* to 'read-only_user_name' identified by 'password';

此命令仅为用户提供从本地主机对数据库的只读访问权限。如果您知道将要安装收集器的主机的主机名或IP地址,请键入以下命令:

grant select on database_name.* to 'read-only_user_name'@'host_name or IP_address' identified by 'password';

主机名必须可由DNS或本地主机文件解析。在mysql提示符处,键入以下命令:

flush privileges;

键入quit

以下是示例命令和确认消息的列表:

mysql> grant select on dbname.* to 'readonlyuser'@'%' identified 
by 'pogo$23';
Query OK, 0 rows affected (0.11 sec)
mysql> flush privileges;
Query OK, 0 rows affected (0.00 sec)
mysql> quit
票数 3
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/20036547

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档