Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

how do you import csv db into mysql

Status
Not open for further replies.

dunskii

Programmer
Sep 14, 2001
107
AU
Hi again,

I have just converted a DB/text database into csv format and now need to import it into mysql...

what is the best tool to do this...and how do you use it... i have tried with both mysqladmin and mysqldump...and i am getting errors with both...

I'm starting to think that its me and not the puter...

thanks again,

dunskii
 
if you have PHP available use PHPMyAdmin - it makes things well simple.
Otherwise you have to be absolutely 100% sure your csv file and its related mysql fields are correct in type and length.
If in doubt convert all fields to VARCHAR and make them slightly too big and try importing the file again. - look for errors , if you get none, its your table structure thats wrong.

from MySQL command,
LOAD DATA LOCAL INFILE '/pathtofile/file' INTO TABLE mytable fields enclosed by '"' terminated by ',' lines terminated by '\n';

Assumes that the file is of format:
"record 1","item 1"," item 2",
"record 2","item 1"," item 2",
"record 3","item 1"," item 2",
last field MUST be terminated as well (comma at the end of each line. ***************************************
Party on, dudes!
 
Thanks for that gerrygerry,

i'm wondering where do i put the csv file to be converted

thanks dunskii

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top