psanjib
psanjib

Reputation: 1299

how to import sql file in command prompt

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

Upvotes: 1

Views: 272

Answers (2)

Ram Sharma
Ram Sharma

Reputation: 8809

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;

Upvotes: 3

Alex
Alex

Reputation: 405

You should run this command in your console, outside of the mysql tool.

Upvotes: 2

Related Questions