0

我有一个大的数据库转储(290mb)。当我使用从 cli 导入时,一切正常!

mysql -u root -piddqd whitestore_com < whitestore_com.sql

当我使用 bash 脚本中的相同命令时,例如:

./build.sh

这是我得到的:

?         (\?) Synonym for `help'.
clear     (\c) Clear the current input statement.
connect   (\r) Reconnect to the server. Optional arguments are db and host.
delimiter (\d) Set statement delimiter.
edit      (\e) Edit command with $EDITOR.
ego       (\G) Send command to mysql server, display result vertically.
exit      (\q) Exit mysql. Same as quit.
go        (\g) Send command to mysql server.
help      (\h) Display this help.
nopager   (\n) Disable pager, print to stdout.
notee     (\t) Don't write into outfile.
pager     (\P) Set PAGER [to_pager]. Print the query results via PAGER.
print     (\p) Print current command.
prompt    (\R) Change your mysql prompt.
quit      (\q) Quit mysql.
rehash    (\#) Rebuild completion hash.
source    (\.) Execute an SQL script file. Takes a file name as an argument.
status    (\s) Get status information from the server.
system    (\!) Execute a system shell command.
tee       (\T) Set outfile [to_outfile]. Append everything into given outfile.
use       (\u) Use another database. Takes database name as argument.
charset   (\C) Switch to another charset. Might be needed for processing binlog with multi-byte charsets.
warnings  (\W) Show warnings after every statement.
nowarning (\w) Don't show warnings after every statement.
ERROR 1064 (42000) at line 1: 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 'mysql  Ver 14.14 Distrib 5.1.66, for debian-linux-gnu (x86_64) 
using readline 6.' at line 1

我不知道为什么会出现这个错误,没有像“mysql Ver 14.14 Distrib 5.1.66, for debian-linux-gnu (x86_64) in dump file using readline 6”这样的字符串。

4

1 回答 1

0

尝试在文本编辑器中打开 whitestore_com.sql 并检查前几行。

看起来 .sql 文件的开头有一些文本应该被注释掉。

它可以打开 mysql 连接,但是从 whitestore_com.sql 获取的命令不是有效的 SQL 语句。

于 2013-04-17T19:28:24.540 回答