最近在研究使用mycat,其中有使用批量数据导入,简单记录一下使用方式。
查看系统属性
mysql>show variables like '%secure%';+--------------------------+-----------------------+| Variable_name | Value |+--------------------------+-----------------------+| require_secure_transport | OFF || secure_auth | ON || secure_file_priv | /var/lib/mysql-files/ |+--------------------------+-----------------------+3 rows in set (0.03 sec)
我们导出的数据必须制定为/var/lib/mysql-files/
,oracle也有类似的设置。
load data 必须指明表,例如我导出表t_card_validate_info2的数据,命令如下
mysql>use ncc;mysql> select * from t_card_validate_info_m into outfile '/var/lib/mysql-files/t_card_validate_info.txt' FIELDS TERMINATED BY ',' OPTIONALLY ENCLOSED BY '"' ESCAPED BY '\\' LINES TERMINATED BY '\n';Query OK, 24892 rows affected (0.53 sec)
查看目录/var/lib/mysql-files/
root@8d3d654c37ac:/# ls /var/lib/mysql-files/t_card_validate_info.txt
vim/cat可以看到纯记录。
导入
load data local infile '/var/lib/mysql-files/t_card_validate_info1.txt' INTO TABLE t_card_validate_info FIELDS TERMINATED BY ',' OPTIONALLY ENCLOSED BY '"' ESCAPED BY '\\' LINES TERMINATED BY '\n' (cert_id, merchant_id, cust_no, cust_name, id_type, id_no, bank_card_type, bank_card_no, cvv, expiry_date, mobile_no, bank_code, bank_name, valid_type, remark, channel_id, channel_name, channel_merchant_id, channe hannel_standby2, channel_standby3, channel_standby4, return_code, return_msg, standard_code, standard_msg, sms_status, verify_status, valid_method, version, create_datetime, update_datetime, standby1, standby2, standby3, standby4, standby5, standby6);