Description:
Trying to add a schema privilege record in Administration for an user account, on a schema that has an _ (underscore) in its name, results in an error dialog and failed query.
The message is as follows:
MySQL Workbench
Error:
[Content]
Error executing 'GRANT SELECT, INSERT, UPDATE, DELETE, CREATE, DROP, REFERENCES, INDEX, ALTER, CREATE TEMPORARY TABLES, LOCK TABLES, CREATE VIEW, SHOW VIEW, CREATE ROUTINE, ALTER ROUTINE, EXECUTE, TRIGGER ON myapp\_new.* TO 'myapp_new'@'%''
You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '\_new.* TO 'myapp_new'@'%'' at line 1.
SQL Error: 1064
The username and DB name both have _ in the name, but the query seems to fail at the DB name.
Mysql is 5.5.8.
How to repeat:
Create a database with an underscore in the name.
Open Administration tab to Mysql. Go to Users and Privileges. Get a test user account created and go to Schema privileges tab. Pick the test user, Add Entry, pick the database with the underscore with the last option in the dialog, Ok, then select privileges from the checkboxes. Hit Apply. The error pops up.
Suggested fix:
Proper handling of underscores (escaping or the lack thereof) and other special/wildcard symbols in the query builder in Schema privileges and elsewhere.