MySQL – Resolving EMS SQL Manager Permission Issues

MySQLpermissionsstored-procedures

I have a strange problem with EMS SQL Manager.

I'm using MySQL 5.5 with linux servers. One of my developers need to edit store procedure, so I grant him:

GRANT CREATE ROUTINE, ALTER ROUTINE ON `testdb`.* TO 'testuser'@'192.168.13.11'

When he clicked edit store in EMS SQL Manager, what he got is:

SELECT command denied to user 'testuser'@'192.168.13.11' for table 'user'

I find out that EMS SQL Manager ask for select privilege in some tables, so I need to grant this user some extra permissions.

GRANT SELECT ON `mysql`.`user` TO 'testuser'@'192.168.13.11';
GRANT SELECT ON `mysql`.`db` TO 'testuser'@'192.168.13.11';
GRANT SELECT ON `mysql`.`tables_priv` TO 'testuser'@'192.168.13.11';
GRANT SELECT ON `mysql`.`columns_priv` TO 'testuser'@'192.168.13.11';
GRANT SELECT ON `mysql`.`procs_priv` TO 'testuser'@'192.168.13.11';

So my question is, WHY EMS SQL Manager need those privileges?
I can create, drop procedure in mysql command line client without problem.

Update

After some investigation, I still do not understand EMS SQL Manager.
This is the action EMS SQL Manager take when click the Compile button.

Executed  : 5/8/2013 3:10:40 PM
Operation : CONNECT
Result    : "OK."

Executed  : 5/8/2013 3:10:40 PM
Operation : show variables like 'character_set_results'
Result    : "OK."

Executed  : 5/8/2013 3:10:40 PM
Operation : SELECT * FROM mysql.user ORDER BY User, Host
Result    : "SELECT command denied to user 'ems'@'192.168.13.11' for table
'user'"

Executed  : 5/8/2013 3:10:40 PM
Operation : DISCONNECT
Result    : "OK."

Executed  : 5/8/2013 3:10:41 PM
Operation : select p.`db`, p.`name`, p.`type`, p.`specific_name`,
p.`language`, p.`sql_data_access`, p.`is_deterministic`, p.`security_type`,
p.`param_list`, p.`returns`, p.`body`, p.`definer`, p.`created`,
p.`modified`, p.`sql_mode`, p.`comment` from `mysql`.`proc` as p where
p.`type` = 'PROCEDURE' and p.`db`='reportingdb' and
p.`name`='100_rpt_campaign_ip'
Result    : "OK."

Executed  : 5/8/2013 3:10:41 PM
Operation : SHOW CREATE PROCEDURE `reportingdb`.`100_rpt_campaign_ip`
Result    : "OK."

So my question, What is the Compile button trying to do? Why does it want to select mysql.user? I think that editing a stored procedure is two steps of drop and re create it, why does it want to do more?

Best Answer

The best thing you can do to understand this behaviour better is to ask the software vendor. If you don't want to grant those permissions, lodging a bug report might be appropriate.

I'm going to hazard a guess that EMS SQL Manager is trying to be too clever, and check whether you have Alter_routine_priv or Create_routine_priv so that it can return a warning or error before it tries sending your ALTER ROUTINE to the database.

Most SQL Editors run lots of queries in the background to support "IntelliSense", speed up common queries, or provide background information, and a lot of the time they just don't make any sense (some of them are downright frightening).