How to bulk change MySQL Triggers DEFINER(如何批量更改 MySQL 触发器 DEFINER)
问题描述
我一直在我们的内部开发服务器上工作,并在我们的 MySQL 5.6.13 服务器上创建 MySQL 触发器.我现在遇到的问题是触发器(总共大约 200 个)是在内部服务器上使用 DEFINER=root@% 创建的.
I've been working on our internal development server and creating MySQL Triggers on our MySQL 5.6.13 server. The problem I now have is the Triggers (around 200 in total) were created with as DEFINER=root@% on the internal server.
现在我想转移到实时生产服务器.但是,在我们的实时服务器上,我们不允许 root 用户进行此访问.因此,如何批量更改所有触发器,使其读取 DEFINER=root@localhost
Now I want to move to the live production server. However on our live server we don't allow this access for user root. Therefore how can I bulk change all my Triggers, so that it reads DEFINER=root@localhost
推荐答案
一种方法:
1) 将触发器定义转储到文件中
1) Dump trigger definitions into a file
# mysqldump -uroot -p --triggers --add-drop-trigger --no-create-info
--no-data --no-create-db --skip-opt test > /tmp/triggers.sql
2) 在您喜欢的编辑器中打开 triggers.sql 文件并使用 Find and Replace 功能来更改 DEFINERs.保存更新的文件.
2) Open triggers.sql file in your favorite editor and use Find and Replace feature to change DEFINERs. Save updated file.
3) 从文件中重新创建触发器
3) Recreate triggers from the file
# mysql < triggers.sql
这篇关于如何批量更改 MySQL 触发器 DEFINER的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:如何批量更改 MySQL 触发器 DEFINER
基础教程推荐
- SQL:使用来自具有相同列名的两个表中的数据... 2021-01-01
- 如何使用 mysql.connector 禁用查询缓存 2022-01-01
- 无法解决整理冲突 2021-01-01
- SSMS 中的权限问题:“对象 'extended_properties'、数据库 'mssqlsystem_resource'、... 错误 229)上的 SELECT 权限被拒绝" 2022-01-01
- SQL 效率:WHERE IN 子查询 vs. JOIN 然后 GROUP 2021-01-01
- SQL Server 实例在登录协商期间返回无效或不受支持的协议版本 2021-01-01
- 是否可以执行按位分组功能? 2021-01-01
- 在 SQL 中连接多个表 2021-01-01
- 需要 MySQL 5.1 中的抽象触发器来更新审计日志 2021-01-01
- 将 SQL Server DateTime 列迁移到 DateTimeOffset 2021-01-01
