set permissions on users mysql with wildcard?
normally one would say:
GRANT ALL PRIVILEGES ON . TO 'monty'@'%'
Can we use a wildcard where we can target specific databases only like this:
GRANT ALL PRIVILEGES ON SHOP%.* TO 'monty'@'%'
We would like to give insert privileges to开发者_C百科 a user on databases that start with prefix "SHOP"
Yes, you can. See the GRANT Syntax. Here's a quote from that page:
The “
_
” and “%
” wildcards are allowed when specifying database names in GRANT statements that grant privileges at the global or database levels. This means, for example, that 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
精彩评论