MySQL event execution failed

现象描述:
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表的权限,所以出错。幸好是在测试环境中出的问题,如果要在生产上出现类似问题,岂不又是一次人为的事故。
  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值