例如,我想在我的服务器上由 WA_ 启动的所有数据库中授予特定用户的选择权限,例如在我的服务器中
我使用以下语法,但它不起作用
grant select on `wa\_%`.`mytable`
to 'myuser'@'localhost'
identified by '123456';
但它给了我这个错误
表 wa_%.mytable' 不存在
MySQL doesn´t allow this type of grants, you can only have wildcards in the database name if you grant privileges on the database or global level. See below exceprt from the 5.5 manual:
The “_” and “%” wildcards are permitted when specifying database names in GRANT statements that grant privileges at the global or database levels.
So for example this will work, because you grant select on database level:
grant select on `wa\_%`.*
to 'myuser'@'localhost'
identified by '123456';
In your example you try to grant access to specific table using wildcard schema name which is not supported by MySQL.
你可以试试这个:
GRANT SELECT ON `wa\_%` . * TO 'myuser'@'localhost' identified by '123456';