I am trying to do a really simple thing – import a table into my database.
mysql> dbname < libmysql.sql;
ERROR 1064 (42000): 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 'dbname <
libmysql.sql' at line 1
I don’t understand, what is wrong. I even tried to do
-u username -h host -p dbname < libmysql.sql
You are mixing up the
mysql>prompt and operating system’s command line prompt. If you have already connected to MySQL and are at themysql>prompt, use theSOURCEcommand to import your file, and be sure you have selected your database withUSEif you didn’t specify it on the command line already…The
<for input redirection is used on the operating system’s command line, as in:It’s also possible to pipe it in, though you wouldn’t want to do this unless the SQL file was being modified by some other process in the pipeline: