user1032531 user1032531 - 1 year ago 96
MySQL Question

What does "\_%" mean regarding MySQL database permissions?

I created a new MySQL user

using phpMyAdmin and when doing so, created a new database with the same name. As seen below,
was given permissions to two databases:

What does the
signify? I later created a new database
, and wish user
to have the same permissions as the first table. Do I need to also add permissions to

enter image description here

Answer Source

% and _ are simply SQL wildcards. The GRANT syntax allows them:

The _ and % wildcards are permitted when specifying database names in GRANT statements that grant privileges at the database level.

You may notice that _ is escaped (\_):

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 ....

It's apparently a way to extend the privileges to any database that starts with homestead_...

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download