Bug #69792 Assigning schema permissions to a user where schema name has an underscore
Submitted: 19 Jul 2013 14:25 Modified: 19 Jul 2013 16:55
Reporter: Kevin Andrews Email Updates:
Status: Duplicate Impact on me:
None 
Category:MySQL Workbench: Administration Severity:S2 (Serious)
Version:5.2.47 CE Revision 10398 OS:Windows (Windows 8)
Assigned to: CPU Architecture:Any
Tags: new user, permissions, schema

[19 Jul 2013 14:25] Kevin Andrews
Description:
When assigning permissions such as SELECT, INSERT to a user on a schema that has an underscore in its name I get the following error

Error executing 'GRANT SELECT, INSERT, UPDATE ON databasename\_enviro.* TO 'username'@'hostname''

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 \_enviro.* TO 'username'@'hostname'' at line 1.

SQL Error: 1064

I've even tried editing the permission row just before clicking save and removing the generated backslash, which still doesn't work.

How to repeat:
Create a schema with an underscore in the name.

Go into a "Server Administrator" connection
Click "Users and Privileges" on the left hand sidebar
Create a mysql user if necessary
Click the schema Privileges tab
Click a user from the second left hand sidebar
Click Add entry
Select schema with underscore in name from the "Selected Schema" selection box
Add permissions needed using check boxes
Click Save Changes

Error box should appear preventing expected action.

Suggested fix:
Escaping the backslash added to escape the underscore seems to be invalidating the generated SQL syntax.

The underscore is enclosed within '' so the SQL will run fine without this being escaped.

Please prevent underscore escaping as it is invalidating the SQL syntax in this instance.
[19 Jul 2013 14:27] Kevin Andrews
'Escaping the backslash added to escape the underscore seems to be invalidating the generated SQL syntax.'

Was supposed to say

'Escaping the underscore with a backslash seems to be invalidating the generated SQL syntax.'

Sorry about the typo.

Kind regards,
Kevin
[19 Jul 2013 16:55] MySQL Verification Team
Thank you for the bug report. Duplicate of http://bugs.mysql.com/bug.php?id=68175 .