Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Loading CSV files into MySQL Workbench

I have a lot of excel/ CSV files that I need to load into my db in MySQL Workbench (I'm on Mac OS X). I've searched around for a good walk-through or tutorial, but I haven't seen anything that clearly explains how to load CSVs into MySQL Workbench....can anyone help?

like image 330
janglosaxon Avatar asked Nov 15 '11 21:11

janglosaxon


2 Answers

are you trying to load csv files into a MySQL table? You can do that easily with the LOAD DATA LOCAL INFILE command.

Example:

LOAD DATA LOCAL INFILE '/data.csv' INTO TABLE my_table FIELDS TERMINATED BY ','

You should be able to enter that command from any interface to MySQL. I'm assuming workbench has a way for you to execute sql queries.

like image 65
Ben English Avatar answered Oct 01 '22 18:10

Ben English


Does it have to be Workbench?

Can you use other MySQL bins?

Here's an example: Create database

Create table

load data local infile '/path/whatever.csv' into table dbName.tableName fields terminated by ',' enclosed by '"' lines terminated by '\n';

like image 30
djdy Avatar answered Oct 01 '22 18:10

djdy