来自bash脚本的Mysql导入错误

时间:2013-04-17 19:06:36

标签: mysql database mysqldump mysqlimport

我有一个大数据库转储(290mb)。当我从cli使用import时一切都还可以!

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,debian-linux-gnu(x86_64)”这样的字符串     使用readline 6.“

1 个答案:

答案 0 :(得分:0)

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

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

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