PDA

View Full Version : Load textfile into mysql


jonas
05-14-1999, 03:06 PM
I Have created a big textfile with inserts, all works ok. Now I want to load it into Mysql.

Any ideas?

I could have done a cut & paste inte mysql> put, since ther s is now support for foreign language in the shell, its not a good idear.

Thanks in advance

//Jonas

dean
05-14-1999, 08:05 PM
1) If you format the text like:
CREATE TABLE tablename (
[nbsp][nbsp]id int(11) DEFAULT '0' NOT NULL auto_increment,
[nbsp][nbsp]data1 blob DEFAULT '' NOT NULL,
[nbsp][nbsp]number integer(200) DEFAULT '' NOT NULL,
[nbsp][nbsp]data2 varchar(200) DEFAULT '' NOT NULL,
[nbsp][nbsp]PRIMARY KEY (id),
[nbsp][nbsp]KEY id (id)
);
INSERT INTO tablename VALUES (null,'characterdata1',432,'moredata1');
INSERT INTO tablename VALUES (null,'characterdata2',123,'moredata2');


2) Then save the above as a text file, and FTP the text file into the root


You can telnet the data into the database using:
mysql -ppassword -uloginname databasename <textfile.txt


This was a brief explaination, but this is how I move a text file into a database. I usually use Excel to format the data, save it as a textfile and fix it with textpad.

You are welcome to email me with specifics if I can explain this further (and if this is what you meant)

dean,[nbsp][nbsp]but not Dean B[nbsp][nbsp];)
------------------
Beta News ? http://www.betazine.com


(I must remember to proof read before pressing send)
[This message has been edited by dean (edited 05-14-99)]