现象描述:
Master中错误日志如下:
tail -100f /data/mysql01.err
[ERROR] Event Scheduler: [test@%][QA.qa_e_p_tf] DROP command denied to user 'test'@'%' for table 'texplor_rent'
[Note] Event Scheduler: [test@%].[QA.qa_e_p_tf] event execution failed.
分析过程:
利用如下SQL 查找Event的定义如下:
由event的定义可知,这个event调用了5个存储过程。根据错误信息
DROP command denied to user 'test'@'%' for table 'texplor_rent'
可知这个event执行失败的原因是没有test@%这个用户没有drop表texplor_rent的权限。
那么是那个存储过程中需要drop表的权限呢?
p_tf_ftw_area,p_tf_ftw_estate。进一步分析这两个存储过程,发现p_tf_ftw_area,p_tf_ftw_estate中有如下语句
TRUNCATE TABLE texplor_rent;
解决方法:
GRANT DROP ON `QA`.`texplor_rent` TO 'test'@'%';
起因:开发人员要求收回数据库用户的create,alter,drop的权限。收回相关的权限后,MySQL在执行event的时候调用的
存储过程中用到了drop表的权限,所以出错。幸好是在测试环境中出的问题,如果要在生产上出现类似问题,岂不又是一次人为的事故。
Master中错误日志如下:
tail -100f /data/mysql01.err
[ERROR] Event Scheduler: [test@%][QA.qa_e_p_tf] DROP command denied to user 'test'@'%' for table 'texplor_rent'
[Note] Event Scheduler: [test@%].[QA.qa_e_p_tf] event execution failed.
分析过程:
利用如下SQL 查找Event的定义如下:
SELECT e.EVENT_DEFINITION from information_schema.EVENTS e
where e.EVENT_SCHEMA='QA'
and e.EVENT_NAME='qa_e_p_tf';
由event的定义可知,这个event调用了5个存储过程。根据错误信息
DROP command denied to user 'test'@'%' for table 'texplor_rent'
可知这个event执行失败的原因是没有test@%这个用户没有drop表texplor_rent的权限。
那么是那个存储过程中需要drop表的权限呢?
select p.`name`,p.body from mysql.proc p
where p.db='QA'
and p.`name` in ('p_tf_ftw_area','p_tf_ftw_district','p_tf_ftw_city','p_tf_ftw_estate','p_tf_ftw_hsrentused')
and p.body like'%texplor_rent%'
由以上SQL 查询出在上述5个存储过程中与texplor_rent表有关的有两个存储过程
p_tf_ftw_area,p_tf_ftw_estate。进一步分析这两个存储过程,发现p_tf_ftw_area,p_tf_ftw_estate中有如下语句
TRUNCATE TABLE texplor_rent;
解决方法:
GRANT DROP ON `QA`.`texplor_rent` TO 'test'@'%';
起因:开发人员要求收回数据库用户的create,alter,drop的权限。收回相关的权限后,MySQL在执行event的时候调用的
存储过程中用到了drop表的权限,所以出错。幸好是在测试环境中出的问题,如果要在生产上出现类似问题,岂不又是一次人为的事故。