Forum Moderators: phranque

Message Too Old, No Replies

Import csv-file into mysql database

         

guangke

2:11 pm on Apr 13, 2006 (gmt 0)

10+ Year Member



I have to import a comma separated file into a mysql database.

How can I do that?

The current phpmyadmin on webhotel cannot import files.

coopster

3:33 pm on Apr 13, 2006 (gmt 0)

WebmasterWorld Administrator 10+ Year Member



Welcome to WebmasterWorld, guangke.

Your host must not allow ]Loading Data into a Table [dev.mysql.com] using the LOAD DATA INFILE [dev.mysql.com] statement. If they don't allow that then it is very unlikely you are going to be able to use mysql in Batch Mode [dev.mysql.com] either.

Outside of that, options start getting slim. You may have to write a server-side script to parse the CSV file and INSERT the data that way.

guangke

7:46 pm on Apr 13, 2006 (gmt 0)

10+ Year Member



Do you know of a opensource php-script that can do that?

Database export / import is a common procedure for most webmaster I guess.

coopster

9:43 pm on Apr 13, 2006 (gmt 0)

WebmasterWorld Administrator 10+ Year Member



No, I don't. I normally write my own code. I would like to think that perhaps phpMyAdmin would do this for you if LOAD DATA was not an option because of permissions.

I just read your first message again though:

The current phpmyadmin ... cannot import files

Maybe it is NOT that your host won't allow you to run those commands but the version of phpMyAdmin that is loaded doesn't support the feature. Perhaps you can connect and run the option from a command line.

mack

9:52 pm on Apr 13, 2006 (gmt 0)

WebmasterWorld Administrator 10+ Year Member Top Contributors Of The Month



Recent versions of phpmyadmin will allow you to import data from a text file. It is very important however to make sure you have your data formatted correctly.

If you click on "SQL" towards the bottom of the page there should be a link to import from text file. On version 2.7 the same link is available from the import tab.

Mack.

coopster

9:58 pm on Apr 13, 2006 (gmt 0)

WebmasterWorld Administrator 10+ Year Member



And if your host doesn't have an updated version loaded, you can always download and install your own in your own space ;)

guangke

10:00 pm on Apr 13, 2006 (gmt 0)

10+ Year Member



The host is Godaddy.com

phpMyAdmin 2.7.0-pl2

No import button

Install my own phpmyadmin?, maybe I try it.