授予多个数据库。 MySQL [英] Grant on multiple databases. MySQL

查看:101
本文介绍了授予多个数据库。 MySQL的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何在多个数据库上授予? MySQL。

How to grant on multiple databases? MySQL.

GRANT SELECT,INSERT,UPDATE,DELETE,CREATE
ON 'databasesprefix%'.*
TO testuser@localhost IDENTIFIED BY 'testpasswd';


推荐答案

来自(5.5)手册


在全局或数据库级别的GRANT语句中指定数据库名称时,允许使用_和%通配符。

The "_" and "%" wildcards are allowed when specifying database names in GRANT statements that grant privileges at the global or database levels.



< _ 只匹配一个字符。如果你想要一个 _ 在你的数据库名称,你必须转义为 \ _ 。还要注意手册中的其他注意事项。

with % matching any number (even zero) of characters, and _ matching exactly one character. if you want a _ in your database name, you have to escape it as \_. also watch the other caveats from the manual.

< UPDATE >另一个答案指出:如果数据库名称包含通配符,则必须使用标识符引号字符引用,反引号(`)< / UPDATE >

<UPDATE>as the other answer points out: if the database name contains wildcards, it has to be quoted with the identifier quote character, the backtick ("`")</UPDATE>

这篇关于授予多个数据库。 MySQL的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆