开发者

mysql (5.1) command line interface and my madness

Got two little problems with this interface. The worse one is that I have a file with a blank line (i have removed the开发者_JAVA百科 SQL to demonstrate!). Tried to use mysql but get this

C:\Users\edheal\Desktop>mysql -e "blank.sql" -h localhost -u test -p
Enter password: *
ERROR 1064 (42000) at line 1: You have an error in your SQL syntax; check the ma
nual that corresponds to your MySQL server version for the right syntax to use n
ear 'blank.sql' at line 1
C:\Users\edheal\Desktop>cat -v "blank.sql"
^M

C:\Users\edheal\Desktop>

What could possibly be the problem? It is just a blank line!

The second - just me being lazy during development. Is it possible to not have a password on the account? Seems that the minimum is one character.


A blank line is not a valid SQL statement therefore it's a syntax error.


Try to use

mysql -h localhost -u test -pYourPasword < "blank.sql"

One some standard installations, the root user does not have any password. But it is not possible to set an existing password to "empty".


The -e or the --execute option expects you to have the SQL command following it:

mysql -e "select ....." -h localhost -u test -p

If you want to execute the commands listed in a file say test.sql you can do:

mysql -h localhost -u test -p < test.sql
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜