mysqlcommand-linemysql-python

mysql 5.7 -e option get error at line 1: unknown command '\u'


This is the code I wrote on command line:

 mysql --user=root --password=root mydb --default-character-set=utf8 -e "set @arg1='[1002,2003,3304]';source run.sql"

However, it throws me this error:

ERROR at line 1: Unknown command '\U'

I have tested if I remove set statement like this and run:

mysql --user=root --password=root mydb --default-character-set=utf8 -e "source run.sql"

The run script file executes.I know I can open the SQL file and change the source code to void this, but this problem is really annoying.

Could anyone have any suggestions to solve this?


Solution

  • Use ; at the end:

    ... -e "set @arg1='[1002,2003,3304]';source run.sql;"
    

    or change source by \.:

    ... -e "set @arg1='[1002,2003,3304]';\. run.sql"