开发者

Huge text-file to mySql

Okay, so I have this utf-8 textfile containing 20 tab-seperated columns of various types (text, integer and date). The file has 2400000 rows (217Mb).

What is 开发者_如何学运维the easist way to get this file transfered to table in my mySql database?


There are CSV import features in MySQL.

For e.g.:

http://dev.mysql.com/doc/refman/5.0/en/mysqlimport.html

And here is an example from one of the comments:

mysqlimport --fields-optionally-enclosed-by=""" --fields-terminated-by=, --lines-terminated-by="\r\n" --user=YOUR_USERNAME --password YOUR_DATABASE YOUR_TABLE.csv


use load data infile


Best way is command line

If you have ssh access to the server, upload the file to server

login in with ssh then

then type 1. mysql 2. use database-name 3. source ./path-to-file.sql

http://dev.mysql.com/doc/refman/5.5/en/mysql-commands.html

and then wait a moment ;)

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜