I have a huge dump file about 40G in size, and I need to dump that back into the database since there are some records are missing after a recovery. Is there any easy way I can covert the INSERT into INSERT IGNORE in the dump file to avoid duplicate entries errors? loading the file to a text editor seems a no go to me. thank you very much in advance
我有一个大约40G的巨大转储文件,我需要将其转储回数据库,因为恢复后有一些记录丢失。有没有简单的方法我可以在转储文件中将INSERT转换为INSERT IGNORE以避免重复条目错误?将文件加载到文本编辑器似乎不适合我。非常感谢你提前
3 个解决方案
#1
10
If your using a unix-like operating system, you can use sed
:
如果你使用类似unix的操作系统,你可以使用sed:
cat file.sql | sed s/"^INSERT"/"INSERT IGNORE"/g > updated.sql
#2
16
There is also a switch for mysqldump
mysqldump还有一个开关
--insert-ignore in mysqldump
--inq-ignore in mysqldump
#3
1
Use a text processing application like sed
from the command line to do the search-replace on your imports.
使用文本处理应用程序(如命令行中的sed)对导入执行搜索替换。
#1
10
If your using a unix-like operating system, you can use sed
:
如果你使用类似unix的操作系统,你可以使用sed:
cat file.sql | sed s/"^INSERT"/"INSERT IGNORE"/g > updated.sql
#2
16
There is also a switch for mysqldump
mysqldump还有一个开关
--insert-ignore in mysqldump
--inq-ignore in mysqldump
#3
1
Use a text processing application like sed
from the command line to do the search-replace on your imports.
使用文本处理应用程序(如命令行中的sed)对导入执行搜索替换。