如何在MySQL中将SELECT ON表名授予PUBLIC [英] How to GRANT SELECT ON tablename to PUBLIC in MySQL
问题描述
我是MySQL的新手.我试图弄清楚如何使表对所有经过身份验证的用户公开可读.在Oracle中,我会说grant select on tablename to public
.该语法不适用于MySQL,我无法弄清楚等效的语法.
I am new to MySQL. I am trying to figure out how to make a table publicly readable to all authenticated users. In Oracle I would say grant select on tablename to public
. This syntax does not work with MySQL and I cannot figure out the equivalent syntax.
推荐答案
每 MySQL文档
MySQL在用户名中不支持通配符.指一个 匿名用户,请使用一个空白的用户名指定一个帐户 GRANT语句:
MySQL does not support wildcards in user names. To refer to an anonymous user, specify an account with an empty user name with the GRANT statement:
GRANT ALL ON test.* TO ''@'localhost'
在这种情况下,从本地主机连接到 匿名用户的正确密码将被允许访问,并带有 与匿名用户帐户相关联的特权.
In this case, any user who connects from the local host with the correct password for the anonymous user will be permitted access, with the privileges associated with the anonymous-user account.
因此,您可以将select
授予localhost
中的任何人,例如
So you can grant select
to anyone from localhost
like
grant select on tablename to ''@'localhost'
(OR)
您可以授予特定域中的所有用户.摘自MySQL文档
You can grant all users from a specific domain. Excerpt from MySQL doc
您可以在主机名中指定通配符.例如, user_name@'%.example.com'适用于该主机中任何主机的user_name example.com域,并且user_name@'192.168.1.%'适用于user_name 用于192.168.1 C类子网中的任何主机.
You can specify wildcards in the host name. For example, user_name@'%.example.com' applies to user_name for any host in the example.com domain, and user_name@'192.168.1.%' applies to user_name for any host in the 192.168.1 class C subnet.
简单形式的user_name是user_name @'%'的同义词.
The simple form user_name is a synonym for user_name@'%'.
这篇关于如何在MySQL中将SELECT ON表名授予PUBLIC的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!