mysql 隔行匯入 MYSQL快速匯入本地資料

2021-10-18 01:33:44 字數 1299 閱讀 8085

mysql提供了從本地檔案快速導資料的命令,具體說明如下:

load data [low_priority | concurrent] [local] infile 'file_name'

[replace | ignore]

into table tbl_name

[character set charset_name]

[[terminated by 'string']

[[optionally] enclosed by 'char']

[escaped by 'char']

[lines

[starting by 'string']

[terminated by 'string']

[ignore number lines]

[(col_name_or_user_var,...)]

[set col_name = expr,...]

實驗:匯入233m檔案的資料

表結構如下:

mysql> show columns from load_file_test;

| field | type | null | key | default | extra |

| mid | int(10) | yes | | null | |

| time | int(10) | yes | | null | |

| type | tinyint(4) | yes | | null | |

3 rows in set (0.12 sec)

檔案資料格式:

1450025|2|1343145600

1586865|1|1343145600

2557075|2|1343145600

2663240|2|1343145600

3787375|2|1343145600

4293640|1|1343145600

執行結果:

mysql> load data local infile '/usr/local/wwwroot/texas/fansprizedata/2012-12' into table load_file_test fields terminated by '|' lines terminated by '\n' (mid,type,time);

query ok, 11116864 rows affected (2 min 25.11 sec)

records: 11116864 deleted: 0 skipped: 0 warnings: 0

二百多兆的資料,大概花了兩分半鐘,還算是比較快的。

mysql 隔行匯入 MySQL 批匯入設定

部分配置方法來自網路,僅作筆記不記錄 建立賬戶 create user 使用者名稱 訪問主機 identified by 密碼 賦予許可權 grant 許可權列表 on 資料庫 to 使用者名稱 訪問主機 修改許可權時在後面加with grant option 在my.ini中加入下面幾個設定 in...

mysql匯入情況 MySQL 匯入資料

mysql 匯入資料 本章節我們為大家介紹幾種簡單的 mysql 匯出的資料的命令。1 mysql 命令匯入 使用 mysql 命令匯入語法格式為 mysql u使用者名稱 p密碼 要匯入的資料庫資料 runoob.sql 例項 mysql uroot p123456 runoob.sql 以上命令...

mysql 匯入 MySQL資料匯出與匯入

工具 mysql mysqldump 應用舉例 匯出匯出全庫備份到本地的目錄 mysqldump u user p passwd h127.0.0.1 p3306 routines default character set utf8 lock all tables add drop databas...