从MySQL转储中删除DEFINER子句。
I have a MySQL dump of one of my databases. In it, there are DEFINER clauses which look like,
我有一个MySQL转储的数据库。在其中,有一些定义子句,
"DEFINER=`root`@`localhost`"
Namely, these DEFINER clauses are on my CREATE VIEW and CREATE PROCEDURE statements. Is there a way to remove these DEFINER clauses from my dump file?
也就是说,这些定义子句在我的创建视图中,并创建过程语句。是否有办法从我的转储文件中删除这些定义子句?
20 个解决方案
#1
71
I don't think there is a way to ignore adding DEFINER
s to the dump. But there are ways to remove them after the dump file is created.
我不认为有一种方法可以忽略在转储中添加定义。但是,在创建转储文件之后,有一些方法可以删除它们。
Open the dump file in a text editor and replace all occurrences of
DEFINER=root@localhost
with an empty string ""在文本编辑器中打开转储文件,并用空字符串替换DEFINER=root@localhost的所有事件。
Edit the dump (or pipe the output) using
perl
:使用perl编辑转储(或管道输出):
perl -p -i.bak -e "s/DEFINER=\`\w.*\`@\`\d[0-3].*[0-3]\`//g" mydatabase.sql
Pipe the output through
sed
:管道输出通过sed:
mysqldump ... | sed -e 's/DEFINER[ ]*=[ ]*[^*]*\*/\*/' > triggers_backup.sql
更多相关文章
- 从Access表将数据导入Excel,从子句中出现语法错误
- 将非常简单的Expression >转换为SQL where子句
- Oracle Pro*c 中sqlca以及oraca的定义和说明
- mysql自定义排序规则函数——field()
- ASP.NET 2.0在SQL Server 2005上自定义分页
- PL/SQL中在package里定义的常量与在package body中的常量有什么
- HSQLDB / Oracle - IN子句中的1000多个项目
- tp3.2结合mysql实现微信自定义分享链接和图文
- Android自定义View底部连续圆环效果