I'm lead to understand that the following grants all proveleges to all databases that name begin with 'xian_', but mysql complains about a syntax error near ''xian_
...
GRANT ALL PRIVILEGES ON 'xian_%.*' TO xian@'192.168.1.%';
What is the correct syntax?
Am I right in thinking that the _
needs escaping to \_
too as it is also a wildcard?
To GRANT ALL privileges to a user , allowing that user full control over a specific database , use the following syntax: mysql> GRANT ALL PRIVILEGES ON database_name. * TO 'username'@'localhost';
In this syntax: First, specify one or more privileges after the GRANT keyword. If you grant multiple privileges, you need to separate privileges by commas. Second, specify the privilege_level that determines the level to which the privileges apply.
To grant a privilege with GRANT , you must have the GRANT OPTION privilege, and you must have the privileges that you are granting. (Alternatively, if you have the UPDATE privilege for the grant tables in the mysql system schema, you can grant any account any privilege.)
The WITH GRANT OPTION clause gives the user the ability to give to other users any privileges the user has at the specified privilege level. To grant the GRANT OPTION privilege to an account without otherwise changing its privileges, do this: GRANT USAGE ON *.
Use `
instead of '
in the database name, and escape the _
GRANT ALL PRIVILEGES ON `xian\_%`.* TO xian@'192.168.1.%';
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With