CSDN-中文IT社區-600萬(www.csdn.net.sql)數據導入示例


原文首發:小菜抓蝦博客 http://zhuaxia.org/blog/post/145

很多菜鳥跟風拼命下載數據庫玩,下是下到了,然后用記事本打開,發現確實是好東西。可是面臨一個問題,如何將CSDN的600萬數據導入到MYSQL數據庫?

我們解壓打開發現www.csdn.net.sql 這個並不是mysql導出的數據庫,而是用#分割開的。所以我們可以用LOAD DATA INFILE來實現快速導入,下面是例子:

 

[root@257139 pwdall]# mysql -uroot -p
Enter password:
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 20793
Server version: 5.1.54-log Source distribution

mysql> show databases;
+--------------------+
| Database           |
+--------------------+
| information_schema |
| csdndb             |
| zhuaxiablog        |
+--------------------+
3 rows in set (0.00 sec)

mysql> use csdndb;
Database changed

mysql> CREATE TABLE `csdnuser`(
    ->  `id` INT(4) NOT NULL AUTO_INCREMENT,
    ->  `username` VARCHAR(255) NOT NULL,
    ->  `userpass` VARCHAR(255) NOT NULL,
    ->  `useremail` VARCHAR(255) NOT NULL,
    ->  PRIMARY KEY (`id`)
    -> ) ENGINE=MYISAM DEFAULT CHARSET=utf8;
Query OK, 0 rows affected (0.00 sec)

mysql> load data local infile '/root/pwdall/www.csdn.net.sql' into table csdnuser fields terminated by ' # ' (username,userpass,useremail);
Query OK, 6428632 rows affected, 2030 warnings (1 min 37.72 sec)
Records: 6428632  Deleted: 0  Skipped: 0  Warnings: 295

 點擊查看原圖

ok,搞定,6428632條數據用了 1分37.72 秒。

ps:本vps才512MB內存。

ps2:大部分泄密數據庫可以在這下載:http://x.com.sb/files/2011/1222/all.zip
 

以下是例子:美國的網速還真TM的快。

[root@257139 pwdall]# wget http://x.com.sb/files/2011/1222/all.zip
--2011-12-23 19:29:44-- http://x.com.sb/files/2011/1222/all.zip
Resolving x.com.sb... 108.60.213.197
Connecting to x.com.sb|108.60.213.197|:80... connected.
HTTP request sent, awaiting response... 200 OK
Length: 940514517 (897M) [application/zip]
Saving to: `all.zip'

100%[======================================>] 940,514,517 11.1M/s in 88s

[root@257139 pwdall]# ls
all.zip
[root@257139 pwdall]# unzip all.zip
Archive:  all.zip
  inflating: 178_1000w_3087.rar     
  inflating: 7k7k_2000w_2047.rar    
  inflating: cdns-chinait-600w.rar  
  inflating: duduniu_66277.rar      
  inflating: duoduo_800w.rar        
 extracting: hostlocw.zip           
  inflating: renren500w_16610.rar   
[root@257139 pwdall]# ls
178_1000w_3087.rar   cdns-chinait-600w.rar  hostlocw.zip
7k7k_2000w_2047.rar  duduniu_66277.rar      renren500w_16610.rar
all.zip              duoduo_800w.rar

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM