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

发布于 2025-01-12 16:21:22 字数 411 浏览 4 评论 0原文

我有一个大型 MySQL 数据库转储(~50GB)(多个数据库备份)。我正在将其恢复到新服务器,这需要很长时间。我认为它花费了这么多时间,因为它是巨大的数据。命令(gunzip <1922-1648-329-75_all-databases.sql.20220305-0000.gz | MySQL -u test -p)也工作正常并开始导入。但一段时间后,我收到一个名为“‘旧’中的未知列‘id’”的错误。我进行了故障排除,发现此错误来自备份文件中的触发器之一。 我真的不需要新服务器上的触发器。 MySQL 中是否有一个命令行选项可以让我在恢复转储时跳过触发器?

下面是我正在使用的 Restore Commane。

枪拉链< 1922-1648-329-75_all-databases.sql.20220305-0000.gz | MySQL -u 测试 -p

I have a large dump(~50GB) of MySQL database(Multiple databases backup). 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. But after some time, I'm getting an error called "Unknown column 'id' in 'OLD'". 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?

Below is the Restore Commane which I am using.

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

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

烟凡古楼 2025-01-19 16:21:22

如果可以的话,使用 --skip-triggers 选项重新创建转储。之后您必须重新创建它们。

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

没有选项可用于禁用导入时的触发器。

Recreate the dump if you can, using the --skip-triggers option. You will have to recreat them afterwards.

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.

故事未完 2025-01-19 16:21:22

重写错误的触发代码。

您有一个 INSERT 触发器,其中包含 OLD,但不受支持。

也许这是复制粘贴错误,但必须在运行备份之前进行此类操作。

下面的链接向您展示了如何选择所有触发器,这应该有助于找到有问题的触发器

如何列出 MySQL 数据库中的所有触发器?

rewrite your faulty trigger code.

you have an INSERT trigger with OLD in it, which is not supported.

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

How do you list all triggers in a MySQL database?

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文