how to import the sql file into the command prompt

advertisements

i am trying to import sql file through putty

below are my details of DB dbname - test, password - test123, username -utest,

i tried the below code

mysql -u utest -p test123 test< /home/path/public_html/file.sql

when i run this command i saw a error message

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 'mysql -u utest -p test123 test < file' at line 1

please suggest how to import sql file

Thank Sanjib


try this

mysql -utest -ptest123  test < /home/path/public_html/file.sql

and make sure that you run this command from your console not in mysql

if you are in mysql prompt than it would be somehting like this

mysql> use test;
mysql> source /home/path/public_html/file.sql;

OR

 mysql>SET autocommit=0; source /home/path/public_html/file.sql; COMMIT;