3

how to Export data from csv file into mysql database? is there any Query or some othr way avial?

Vivek
  • 43
  • 1
  • 6
  • http://stackoverflow.com/questions/7442285/please-help-me-to-load-csv-to-mysql –  Mar 14 '13 at 06:40

2 Answers2

2

I think you mean IMPORT., here's how:

load data local infile 'yourCSVfilepath.csv' into table tableNameHERE
fields terminated by ','
optionally enclosed by '"'
lines terminated by '\r\n'
John Woo
  • 258,903
  • 69
  • 498
  • 492
1

To Export data to csv from Mysql use this

SELECT *
INTO OUTFILE '/tmp/tablename.csv'
FIELDS TERMINATED BY ','
ENCLOSED BY '"'
ESCAPED BY '\\'
LINES TERMINATED BY '\n'
FROM tablename

To import csv to Mysql use this

LOAD DATA INFILE 'c:/tablename.csv' INTO TABLE tablename
divyabharathi
  • 2,187
  • 17
  • 12