1

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

Quentin
948k135 gold badges1.3k silver badges1.4k bronze badges
asked Jan 8, 2015 at 13:59
2
  • there should not be a space between -p and test123 Commented Jan 8, 2015 at 14:02
  • possible duplicate of stackoverflow.com/questions/7316507/… Commented Jan 8, 2015 at 14:05

2 Answers 2

3

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;
answered Jan 8, 2015 at 14:04

4 Comments

it works fine, one question to you. I rememebr, i have tried the same command and it was successfully imported. But today i don't understand why not imported
may be you are missing some minor thing :)
@psanjb: Maybe you had hit CTRL+D to exit mysql first.
@psanjib please mark it as correct so that other user can get the help from your question
2

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

answered Jan 8, 2015 at 14:02

Comments

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.