0

I am having some problems with mysql importing text into a database. My .txt file looks like this:

a.txt

Pattern: 1

Address: 18PhQkzkzP6QUmWuiddhJ2YrGKZKRmV3j

Privkey: 5JRpLiEcq57ijgfVGmmE19V1F29zPkwWjTQinJJJpfYtqA3ZcbY

Pattern: 1

Address: 18zvgu7k8WxAnwgghdudhdzYRCo7aEVPBUU

Privkey: 5JmAp8QgujxDhwJHwgkW9FkiuWEkSDwZL73Xu8ihAY2fy3Kjmn3  

etc....

I want to import this txt. file into a database called bitcoin with the table a from a.txt. All lines from the "Pattern: 1" should disappear and the table "a" should only have two columns:" address and privkey" which address as the prim. key.

mysql> LOAD DATA LOCAL INFILE "/home/weber/Desktop/a.txt" INTO TABLE a

-> FIELDS TERMINATED BY ':'

-> LINES STARTING BY 'Address' 

-> IGNORE 1 LINES;

Seems not working very well, anyone with some mysql knowledge could give me a hint, thanks.

4

1 回答 1

0

您似乎认为该文件可以将文本文件中的多行用于一行。您需要每行使用一行。

尝试:

Pattern:Address:Privkey
1:18PhQkzkzP6QUmWuiddhJ2YrGKZKRmV3j:5JRpLiEcq57ijgfVGmmE19V1F29zPkwWjTQinJJJpfYtqA3ZcbY
1:18zvgu7k8WxAnwgghdudhdzYRCo7aEVPBUU:5JmAp8QgujxDhwJHwgkW9FkiuWEkSDwZL73Xu8ihAY2fy3Kjmn3  

并且不要在命令中使用“LINES STARTING BY 'Address'”。阅读http://dev.mysql.com/doc/refman/5.1/en/load-data.html或类似的东西,了解如何正确使用它。

于 2014-02-22T09:16:23.663 回答