MySQL:导入时忽略错误?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/11263018/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-31 14:00:02  来源:igfitidea点击:

MySQL: ignore errors when importing?

mysqldatabaseimport

提问by Dustin

I am importing a fairly large database. The .sqlfile has almost 1,000,000 lines in it. Problem is that I am getting a syntax error when trying to import the database. It says:

我正在导入一个相当大的数据库。该.sql文件中有近 1,000,000 行。问题是我在尝试导入数据库时​​遇到语法错误。它说:

ERROR 1064 (42000) at line 8428420: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '
Fatal error: Maximum execution time of 600 seconds exceeded in

第 8428420 行的 ERROR 1064 (42000):您的 SQL 语法有错误;检查与您的 MySQL 服务器版本相对应的手册,了解在“
致命错误:超过 600 秒的最大执行时间 ”附近使用的正确语法

Normally I'd just open the .sql file and fix the error. But my computer is really struggling to open this file.

通常我只打开 .sql 文件并修复错误。但是我的电脑真的很难打开这个文件。

Is there any way I can ignore errors when importing a MySQL database?

导入 MySQL 数据库时有什么方法可以忽略错误吗?

回答by Craig Boobar

Use the --force(-f) flag on your mysql import. Rather than stopping on the offending statement, MySQL will continue and just log the errors to the console.

在 mysql 导入中使用--force( -f) 标志。MySQL 不会停止在有问题的语句上,而是继续并将错误记录到控制台。

For example:

例如:

mysql -u userName -p -f -D dbName < script.sql