mysql - 如何在 MySQL 中将 SELECT ON 表名授予 PUBLIC

标签 mysql

我是 MySQL 新手。我想弄清楚如何使所有经过身份验证的用户都可以公开读取表格。在 Oracle 中,我会说 grant select on tablename to public。此语法不适用于 MySQL,我无法找出等效的语法。

最佳答案

根据 MySQL Documentation

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/

相关文章:

安卓+mysql : Connection class returns a Null object

mysql - 使用 Entity Framework 6 和 MySql 的 DbUpdateConcurrencyException

mysql - 如何在 Talend 中的数据库之间进行增量同步

PHP 和 MySQL 注入(inject)预防

php - mysql_insert_id() 0,但插入成功

java - 错误 : Client does not support authentication protocol requested by server; consider upgrading MySQL client

php:在某些情况下替换每个img src

mysql - 删除巨大的mysql表中的所有字段

php - WordPress/mySQL 如何将标签与帖子关联起来

C# MYSQL datagridview 中的多表