MySQL 在第 1 行的“?■/”附近导入 mysqldump 文件时出现 ERROR 1064 (42000)
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/21752550/
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
While importing mysqldump file ERROR 1064 (42000) near '?■/ ' at line 1
提问by Pavan Kumar N
Cannot import the below dump file created by mysqldump.exe in command line of windows
无法在 Windows 的命令行中导入由 mysqldump.exe 创建的以下转储文件
/*!40101 SET @saved_cs_client = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `attachment_types` (
`ID` int(11) NOT NULL AUTO_INCREMENT,
`DESCRIPTION` varchar(50) DEFAULT NULL,
`COMMENTS` varchar(256) DEFAULT NULL,
PRIMARY KEY (`ID`),
UNIQUE KEY `UK_ATTACHMENT_TYPES___DESCRIPTION` (`DESCRIPTION`)
) ENGINE=InnoDB AUTO_INCREMENT=4 DEFAULT CHARSET=latin1;
While importing the file in command line
在命令行中导入文件时
mysql --user=root --password=root < mysqldumpfile.sql
It throws error
它抛出错误
ERROR 1064 (42000) near ' ■/ ' at line 1
Somebody please help me.
有人请帮助我。
回答by Pavan Kumar N
Finally I got a solution
最后我得到了一个解决方案
We need two options
我们需要两个选择
--default-character-set=utf8
: This insures UTF8 is used for each field--result-file=file.sql
: This option prevents the dump data from passing through the Operating System which likely does not use UTF8. Instead it passes the dump data directly to the file specified.
--default-character-set=utf8
: 这确保了 UTF8 用于每个字段--result-file=file.sql
:此选项可防止转储数据通过可能不使用 UTF8 的操作系统。相反,它将转储数据直接传递到指定的文件。
Using these new options your dump command would look something like this:
使用这些新选项,您的转储命令将如下所示:
mysqldump -u root -p --default-character-set=utf8 --result-file=database1.backup.sql database1
While Importing you can optionally use:
在导入时,您可以选择使用:
mysql --user=root --password=root --default_character_set utf8 < database1.backup.sql
Source:http://nathan.rambeck.org/blog/1-preventing-encoding-issues-mysqldump
来源:http: //nathan.rambeck.org/blog/1-preventing-encoding-issues-mysqldump
回答by valex
It seems that the input file (mysqldumpfile.sql) was created in UTF-8
encoding so these first 3 bytes "at line 1" invisible to you in the .SQL file is the byte order mark (BOM) sequence
似乎输入文件 (mysqldumpfile.sql) 是在UTF-8
编码中创建的,因此在 .SQL 文件中这些前 3 个字节“在第 1 行”对您不可见是字节顺序标记 (BOM) 序列
So try to change default character set to UTF-8
所以尝试将默认字符集更改为 UTF-8
mysql --user=root --password=root --default_character_set utf8 < mysqldumpfile.sql
回答by wired00
If you need to import database, this is the import command required on Windows:
如果您需要导入数据库,这是 Windows 上所需的导入命令:
mysql --user=root --password=root --default_character_set utf8 database2 < database1.backup.sql