Jump to content

[SOLVED] Importing text files into database for MySQL 5.0


twilitegxa

Recommended Posts

How do I need to set up the records in the text file in order to import the records into my MySQL database? I am using MySQL 5.0.51b and I currently have a text file saved with each field separated by a comma and this was able to be imported by Microsoft Access in this format, but is not accepted by MySQL. What format do I need to put my records in for the text file to be imported into the MySQL database? I am running a program call WampServer, if that helps.

I tried changing the extention, but I still recived an error about the syntax. I have each field like: 

 

"field1","field2","field3"....and so on.

 

Is this right? Maybe the character set is wrong for some reason? When I import, it is set to utf8. I tried saving it with the same character set, but it's still not working. This is the error I receive:

 

#1064 - You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '"Sailor Moon","Serena Tsukino","Purity And The Soul","13","06","30","1978","4","' at line 1

Start by checking if your favorite/available database management tool has a CSV import option. If not, then take a look at the LOAD DATA LOCAL INFILE query statement - http://dev.mysql.com/doc/refman/5.0/en/load-data.html

I'm not using a query. It's kind of a built-in feature of the program I'm using. It has an import option. The program is WampServer. I didn't know I could use a query to do it. Can anyone help e out with how to do the query? It might be easier that way possibly. I am still very new to MySQL and PHP.

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.