Re: Best format to insert into mysql??
| From: | Matthew Ballard | Date: | Mon, 04 Dec 2000 05:25:59 +0000 |
| Subject: | Re: Best format to insert into mysql?? | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-28517@lists.php.net to get a copy of this message | ||
He should either create a file with text where the columns are seperated by tabs, and then he can use the following syntax from the mysql client program (it could be done with a script if he can't access the text client program):
LOAD DATA INFILE '/path/to/file/filename' INTO TABLE tblname;
if he uses a different seperator, or uses quotes:
LOAD DATA INFILE '/path/to/file/filename' INTO TABLE tblname FIELDS TERMINATED BY 'seperator' OPTIONALLY ENCLOSED BY '"' LINES TERMINATED BY '\n';
One other option would be to install mysql on his computer (with a webserver and PHP if he wants to use a script), and then use the mysqldump program to output the structure and tables, that can be directly imported to another script. The dump program can be used like this:
mysqldump --opt databasename > backup-file.sql
and then on the remote server, delete the contents of the database, and then do:
mysql databasename < backup-file.sql
You can read more about mysqldump at:
http://www.mysql.com/documentation/mysql/commented/manual.php?section=mysqldump
Matthew
At 06:43 PM 12/3/2000 -0800, you wrote:
Hi all, A friend of mine wants to put a lot of data (small VARCHARS as well as 1000 word blobs) into mysql. But he doesnt have the net connection to sit there and input it all into a admin page which inserts it in one by one. So what is the best format he can save it in, so the data can easily be inserted into Mysql??? And what command would I use??