简体   繁体   English

使用 Linux 命令恢复 MySQL 转储时跳过触发器

[英]Skip triggers while restoring MySQL dump using Linux command

I have a large dump(~50GB) of MySQL database(Multiple databases backup).我有一个 MySQL 数据库(多数据库备份)的大转储(~50GB)。 I am restoring it to a new Server which is taking a long time.我正在将它恢复到需要很长时间的新服务器。 I think it is taking this much time because it is huge data.我认为它花费了这么多时间,因为它是巨大的数据。 the command ( gunzip < 1922-1648-329-75_all-databases.sql.20220305-0000.gz | MySQL -u test -p) also working fine and it started importing.命令(gunzip < 1922-1648-329-75_all-databases.sql.20220305-0000.gz | MySQL -u test -p)也工作正常,它开始导入。 But after some time, I'm getting an error called "Unknown column 'id' in 'OLD'".但一段时间后,我收到一个名为“'OLD' 中的未知列'id'”的错误。 I have troubleshot and found that this error is coming from one of the triggers in the backup file.我有故障,发现此错误来自备份文件中的触发器之一。 I don't really need triggers on the new server.我真的不需要新服务器上的触发器。 Is there a command-line option to use in MySQL which will allow me to skip the triggers while restoring the dump?在 MySQL 中是否有一个命令行选项可以让我在恢复转储时跳过触发器?

Below is the Restore Commane which I am using.下面是我正在使用的 Restore Commane。

gunzip < 1922-1648-329-75_all-databases.sql.20220305-0000.gz | gunzip < 1922-1648-329-75_all-databases.sql.20220305-0000.gz | MySQL -u test -p MySQL -u 测试 -p

Recreate the dump if you can, using the --skip-triggers option.如果可以,请使用 --skip-triggers 选项重新创建转储。 You will have to recreat them afterwards.之后您将不得不重新创建它们。

https://dev.mysql.com/doc/refman/5.7/en/mysqldump.html#option_mysqldump_triggers https://dev.mysql.com/doc/refman/5.7/en/mysqldump.html#option_mysqldump_triggers

There is no option available to disable the triggers on import.没有可用于在导入时禁用触发器的选项。

rewrite your faulty trigger code.重写错误的触发代码。

you have an INSERT trigger with OLD in it, which is not supported.您有一个不支持的带有 OLD 的 INSERT 触发器。

Maybe it is acopy paste error, but such things must be made before making a backup runs.也许这是一个复制粘贴错误,但在进行备份运行之前必须进行此类操作。

the link below shows you how to select all triggers, this should help to find the problematic trigger下面的链接向您展示了如何 select 所有触发器,这应该有助于找到有问题的触发器

How do you list all triggers in a MySQL database? 如何列出 MySQL 数据库中的所有触发器?

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM