MySQL: Permissions

Create a user:

CREATE USER [email protected] IDENTIFIED BY 'password';

Rename a user:

RENAME USER [email protected] TO test@'%';

Grant all:

GRANT ALL PRIVILEGES ON <database>.<table> TO <user>@<host>;

Grant all to a database starts with “test_”:

GRANT ALL PRIVILEGES ON `test\_%`.* TO test@localhost;

From MySQL website:

The _ and % wildcards are permitted when specifying database names in GRANT statements that grant privileges at the database level (GRANT ... ON db_name.*). This means, for example, that to use a _ character as part of a database name, specify it using the \ escape character 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 ...).

REFERENCES:


Comments

Leave a Reply

Your email address will not be published. Required fields are marked *