1

I need to import.csv file throught windows command line terminal in defined table.

I was trying this command :

C:\xampp\mysql\bin\mysql -u root -p dbname dbtablename < C:\xampp\htdocs\site\csvfolder\import.csv

But it does not works. What am I doing wrong ?

2 Answers 2

0

I believe you have to use LOAD DATA INFILE for csv files. See here: https://dev.mysql.com/doc/refman/5.7/en/load-data.html.

You can run it from the command line like so:

mysql -u root dbname -p -e "load data infile 'c:/path/to/file.csv' into table dbtablename"
2
  • so there is no terminal solution...need to work in mysql anyway ?
    – John
    Oct 15, 2017 at 19:23
  • Try: mysql -u root -p dbname -e "load data infile 'c:/path/to/file.csv' into table dbtablename". I edited my answer to include this.
    – Joe
    Oct 15, 2017 at 19:50
0

Please put your CSV file in the same location where you run the command and try again.

(like : c:\xampp\mysql\bin\mysql\import.csv)

c:\xampp\mysql\bin\mysql -u root -p database_name table_name < import.csv

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.