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 DEFINERs to the dump. But there are ways to remove them after the dump file is created.

我不认为有一种方法可以忽略在转储中添加定义。但是,在创建转储文件之后,有一些方法可以删除它们。

  1. Open the dump file in a text editor and replace all occurrences of DEFINER=root@localhost with an empty string ""

    在文本编辑器中打开转储文件,并用空字符串替换DEFINER=root@localhost的所有事件。

  2. 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
    
  3. Pipe the output through sed:

    管道输出通过sed:

    mysqldump ... | sed -e 's/DEFINER[ ]*=[ ]*[^*]*\*/\*/' > triggers_backup.sql
    

更多相关文章

  1. 从Access表将数据导入Excel,从子句中出现语法错误
  2. 将非常简单的Expression >转换为SQL where子句
  3. Oracle Pro*c 中sqlca以及oraca的定义和说明
  4. mysql自定义排序规则函数——field()
  5. ASP.NET 2.0在SQL Server 2005上自定义分页
  6. PL/SQL中在package里定义的常量与在package body中的常量有什么
  7. HSQLDB / Oracle - IN子句中的1000多个项目
  8. tp3.2结合mysql实现微信自定义分享链接和图文
  9. Android自定义View底部连续圆环效果

随机推荐

  1. android设置横屏代码
  2. Android(安卓)Studio 时间选择器创建
  3. Android事件分发机制完全解析(终极版二)
  4. Android真机调试 Android.Util.AndroidRu
  5. Android的EditText设置光标一直显示而不
  6. 【Android - 进阶】之事件分发机制
  7. ANDROID自定义SCROLLVIEW
  8. Android 统计图表引擎AChartEngine(五) -
  9. Android Init Language(安卓初始化语言)
  10. Android百度地图SDK—地图标记