我是 MySQL 新手。我想弄清楚如何使所有经过身份验证的用户都可以公开读取表格。在 Oracle 中,我会说 grant select on tablename to public
。此语法不适用于 MySQL,我无法找出等效的语法。
最佳答案
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
中的任何人,例如
grant select on tablename to ''@'localhost'
(或)
您可以授予来自特定域的所有用户。摘自 MySQL 文档
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.
The simple form user_name is a synonym for user_name@'%'.
关于mysql - 如何在 MySQL 中将 SELECT ON 表名授予 PUBLIC,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23815765/