Home > Database > Mysql Tutorial > How to modify definer in mysql

How to modify definer in mysql

WBOY
Release: 2022-05-19 17:30:46
Original
2974 people have browsed it

Modification method: 1. Use "update mysql.proc set definer=..." to modify the definer of the function; 2. Use "update mysql.EVENT set definer=..." to modify the definer of the event.

How to modify definer in mysql

The operating environment of this tutorial: windows10 system, mysql8.0.22 version, Dell G3 computer.

How to modify the definer of mysql

1. Modify the definer of function and procedure

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

2. Modify the definer of event

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

3. Modify the definer of the view

Compared with modifying the function, it is more troublesome:

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‘;
Copy after login

Just execute the query statement again.

4. Modify the trigger's definer

Currently there is no specific and convenient method. You can use tools such as HeidiSQL, sqlyog, etc. to modify them one by one. Note that it is necessary to lock the table before making changes, because if it is triggered by changes in other tables during the change process, it will cause data inconsistency.

Recommended learning: mysql video tutorial

The above is the detailed content of How to modify definer in mysql. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template