我使用 phpMyAdmin 创建了一个新的 MySQL 用户 homestead
,并且在执行此操作时,创建了一个同名的新数据库。如下所示,homestead
被授予对两个数据库的权限:homestead
和 homestead\_%
。
\_%
表示什么?后来我创建了一个新的数据库 laravel
,并希望用户 homestead
具有与第一个表相同的权限。我还需要向 laravel\_%
添加权限吗?
最佳答案
%
和 _
只是 SQL 通配符。 GRANT syntax允许他们:
The _ and % wildcards are permitted when specifying database names in GRANT statements that grant privileges at the database level.
您可能会注意到 _
已转义 (\_
):
if you want to use a
_
character as part of a database name, you should specify it as\_
in the GRANT statement, to prevent the user from being able to access additional databases matching the wildcard pattern; for example, GRANT ... ON `foo\_bar`.* TO ....
这显然是一种将权限扩展到任何以 homestead_...
开头的数据库的方法
关于mysql - 关于 MySQL 数据库权限, "\_%"意味着什么?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40791763/