Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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 a user on databases that start with prefix "SHOP"

like image 282
Jorre Avatar asked Jul 10 '10 14:07

Jorre


People also ask

How do I grant user privileges to user in MySQL?

Grant permissions to a MySQL user accountmysql> GRANT SELECT, INSERT ON strongdm. * TO 'local_user'@'localhost'; To create a user with the same privileges as the root user, use the following command, which grants global privileges to the user Janet connecting via localhost: mysql> GRANT ALL ON *.

Can we use wildcard in MySQL?

MySQL WildcardsA wildcard character is used to substitute one or more characters in a string. Wildcard characters are used with the LIKE operator. The LIKE operator is used in a WHERE clause to search for a specified pattern in a column.

How do I change user permissions in MySQL?

You can't currently change a user's privileges in the control panel, so to do so you need to use a command-line MySQL client like mysql . After you create a user in the cluster, connect to the cluster as doadmin or another admin user.

What is the wildcard character in MySQL?

MySQL provides two wildcard characters for constructing patterns: percentage % and underscore _ . The percentage ( % ) wildcard matches any string of zero or more characters. The underscore ( _ ) wildcard matches any single character.


1 Answers

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

like image 184
Mike Avatar answered Sep 24 '22 05:09

Mike