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

2

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;
Sign up to request clarification or add additional context in comments.

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.

Comments

Your Answer

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.