I'd like to assign a user all privileges on tables which have a specific prefix, eg. 'abc_'
我想要分配一个用户所有的特权在表上有一个特定的前缀,如。“abc_”
I'm aware of the use of the wildcard to select all tables thus:
我知道通配符用于选择所有表,因此:
GRANT ALL ON dbname.* TO ...
Essentially, what I'd like to do is:
本质上,我想做的是:
GRANT ALL ON dbname.abc_* TO ...
This doesn't work so I'm wondering if there is a solution, perhaps using LIKE? (Which I've tried; as yet to no avail).
这行不通,所以我想知道是否有解决方案,也许用LIKE?(我试过了;到目前为止还没用。
2 个解决方案
#1
1
$ php -f pcre_grant.php -- localhost root password database user1 abc_ ALL
pcre_grant.php will look like:
<?php
list($script, $db_host, $db_username, $db_password, $db_name, $regexp, $username, $perms) = $argv;
$link = mysql_connect($db_host, $db_username, $db_password);
mysql_select_db($db_name);
$result = mysql_query("SHOW TABLES");
while($row = mysql_fetch_row($result)){
if(preg_match('/'.$regexp.'/',$row[0]))
mysql_query("GRANT ".$perms." ON `".$db_name."`.`".$row[0]."` TO ".$username);
}
mysql_close($link);
?>
#2
3
Nope, sorry. Have to do them one at a time (with, of course, the option to do so programatically).
不,对不起。必须一次做一件(当然,要有编程的选择)。
#1
1
$ php -f pcre_grant.php -- localhost root password database user1 abc_ ALL
pcre_grant.php will look like:
<?php
list($script, $db_host, $db_username, $db_password, $db_name, $regexp, $username, $perms) = $argv;
$link = mysql_connect($db_host, $db_username, $db_password);
mysql_select_db($db_name);
$result = mysql_query("SHOW TABLES");
while($row = mysql_fetch_row($result)){
if(preg_match('/'.$regexp.'/',$row[0]))
mysql_query("GRANT ".$perms." ON `".$db_name."`.`".$row[0]."` TO ".$username);
}
mysql_close($link);
?>
#2
3
Nope, sorry. Have to do them one at a time (with, of course, the option to do so programatically).
不,对不起。必须一次做一件(当然,要有编程的选择)。