mysql怎么修改definer

 2022-07-14    609  

mysql怎么修改definer

1.修改function、procedure的definer

mysql怎么修改definer

select definer from mysql.proc;  -- 函数、存储过程
update mysql.proc set definer=‘user@localhost‘; -- 如果有限定库或其它可以加上where条件

2.修改event的definer

select DEFINER from mysql.EVENT; -- 定时事件
update mysql.EVENT set definer=‘ user@localhost ‘;

3.修改view的definer

相比function的修改麻烦点:

select DEFINER from information_schema.VIEWS;
select concat("alter DEFINER=`user`@`localhost` SQL SECURITY DEFINER VIEW ",TABLE_SCHEMA,".",TABLE_NAME," as ",VIEW_DEFINITION,";") from information_schema.VIEWS where DEFINER<>‘user@localhost‘;

查询出来的语句再执行一遍就好了。

4.修改trigger的definer

目前还没有具体方便的方法,可以借助工具端如HeidiSQL、sqlyog等来一个个修改。注意改前有必要锁表,因为如果改的过程中有其它表改变而触发,会造成数据不一致。


  •  标签:  
  • mysql
  •  

原文链接:https://77isp.com/post/2023.html

=========================================

https://77isp.com/ 为 “云服务器技术网” 唯一官方服务平台,请勿相信其他任何渠道。