Database Administrators Stack Exchange is a question and answer site for database professionals who wish to improve their database skills and learn from others in the community. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I have a CSV file that has 2 columns


I have a table in my database that has the same columns + some extra columns.

Now I would like to update my db table using that csv file. I mean like this

UPDATE `mytable` SET `email` = 'csvemail' WHERE `name` = 'csvname'

Can someone help me to do that from my ubuntu terminal?

share|improve this question

MySQL has built-in support for importing data from CSV files, just use the command-line client :

mysql -u <user> -p

(replace <user> with your MySQL username and enter the password when asked to)

Then, tell MySQL to use your database :

USE <database>;

(replace <database> with the database name)

And finally, use this to import everything from your CSV file :


(replace <path> with the full path to the CSV file such as /home/user/file.csv and <table> with the table name).

Look at this question and this one that may be related to your question.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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