MySQL修改存储过程和函数、事件、触发器、视图的DEFINER MySQL修改存储过程和函数、事件、触发器、视图的DEFINER
新建存储过程、视图、函数等这些功能模块时,⽤了⽤户A,由于项⽬不停的迭代和⼈员的流动,结果⽤户A不知道什么时候被删除了,只有⽤户B,这个时候使⽤⽤户B运⾏之前创建的存储过程等功能,就会出现 DEFINER对应不上的错误。
例如:
ERROR 1142 (42000): SELECT command denied to user'user1'@'localhost'for table'user'
数据库视图查看、修改存储过程和函数的DEFINER
查看:
做运维必须会linux吗mysql> select db,name,type,definer from mysql.proc where db='caimei' limit 0,1 \G;
*************************** 1. row ***************************
db: caimei
name: addNewUserForDiTui
type: PROCEDURE
definer: developer@%
文字上下居中怎么弄css
1 row in set (0.00 sec)
修改:
mysql> update mysql.proc set definer='user@localhost'where db = 'caimei'and name = 'extract_schema_from_file_name';
查看、修改事件的DEFINER
查看:
mysql> select definer from mysql.event;
修改:
mysql查看所有存储过程
mysql> update mysql.event set definer='user@localhost' name = 'xxxxxx';
查看、修改触发器的DEFINER
没有更⽅便的⽅法,只能删除重建,或者⼿动修改。改前最好锁表,改的过程中如果有其它表改变⽽触发,会造成数据不⼀致。
查看:
mysql> select * from iggers where TRIGGER_SCHEMA = 'caimei';
修改:
汇编语言延时程序怎么写mysql> flush tables with readlock
mysql> drop trigger trigger_name;
mysql> delimiter ;;
>create definer=`user`@`%` trigger trigger_name before
>delete on table_name for each row
>begin
>insert ……;
>end;;
>delimiter ;
常见的c语言变量名mysql> unlock tables
查看、修改视图的DEFINER
修改视图有些复杂,不过还是有办法的。
查看:
select * from information_schema.views where table_schema = 'xxxxxx';
修改:
select concat("alter definer=`developer`@`%` sql security definer view ",table_schema,".",table_name," as ",view_definition,";") as'view'from information_s 运⾏后,会得到⼀堆通过concat拼装好的sql语句,稍作编辑,放在客户端执⾏即可。

版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系QQ:729038198,我们将在24小时内删除。