【发布时间】:2013-09-03 11:48:52
【问题描述】:
我使用来自this 线程的指南成功创建了myDb1 数据库的mysqldump 文件myDump.sql。我还创建了第二个数据库myDb2,导航到包含myDump.sql 的目录并尝试将其还原到新数据库myDb2 但失败了,我尝试了两种方法:
> mysql -u root -p myDb2 < myDump.sql;
> -- entered password
和:
> mysql -u root -p
mysql> -- entered password
mysql> USE myDb2;
mysql> SOURCE myDump.sql;
两者都有相同的错误信息:
ERROR:
ASCII '\0' appeared in the statement, but this is not allowed unless option --binary-mode is enabled and mysql is run in
non-interactive mode. Set --binary-mode to 1 if ASCII '\0' is expected. Query: ' ■-'.
我还想知道是否需要为新数据库使用与旧数据库相同的数据库名称。我尝试使用不同且相同的名称,但结果错误相同。
【问题讨论】:
-
尝试运行
file myDump.sql,它会打印什么? (如果你在 linux 上) -
@user4035 我没有 linux。我使用windows powerShell。尝试以
mysql> SOURCE myDump.sql;运行 myDump.sql,我得到ERROR: Failed to open file 'myDump.sql', error: 2 -
这个文件是文本文件吗?用文本编辑器检查一下。
-
@user4035 这是一个
.sql文件,运行mysqldump生成。
标签: mysql mysqldump database-backups