mysql 查看函数的所属用户和已存在的函数

复现方式:
    Delete FROM user Where User='test' and Host='%';  
   flush privileges; 


修复流程:
1.用root用户删除两个函数,语句分别为
    DROP FUNCTION IF EXISTS currval;
    DROP FUNCTION IF EXISTS nextval;
2.然后用程序用户(sharding_slave)创建函数,创建语句为:
   DELIMITER $
CREATE FUNCTION currval (seq_name VARCHAR(50))
RETURNS BIGINT(20)
LANGUAGE SQL
DETERMINISTIC
CONTAINS SQL
SQL SECURITY DEFINER
COMMENT ''
BEGIN
DECLARE value BIGINT(20);
SET value = 0;
SELECT current_value INTO value
FROM key_sequence
WHERE table_name = seq_name;
RETURN value;
END
$
DELIMITER ;

DELIMITER $
CREATE FUNCTION nextval (seq_name VARCHAR(50))
RETURNS BIGINT(20)
LANGUAGE SQL
DETERMINISTIC
CONTAINS SQL
SQL SECURITY DEFINER
COMMENT ''
BEGIN
UPDATE key_sequence
SET current_value = current_value + increment
WHERE table_name = seq_name;
RETURN currval(seq_name);
END
$
DELIMITER ;

3.查看definer 是否为 程序用户
select db,name,type,created,definer from mysql.proc where db like 'dbname;

 

 

修改definer:

参考博客:https://www.cnblogs.com/zejin2008/p/4767531.html

posted on 2021-01-06 14:19  杨秀峰blog  阅读(544)  评论(0编辑  收藏  举报

导航