先導出數據
mysql> select * from timer_gps_posinfo where time>'2017-01-01 00:00' and time <'2017-01-02 00:00' into outfile '/home/posinfo.txt' fields terminated by ',';
報錯:
ERROR 1290 (HY000): The MySQL server is running with the --secure-file-priv option so it cannot execute this statement
解決:兩種方法
1.使用
mysql>SHOW VARIABLES LIKE "secure_file_priv"; +------------------+-----------------------+ | Variable_name | Value | +------------------+-----------------------+ | secure_file_priv | /var/lib/mysql-files/ | +------------------+-----------------------+ 1 row in set (0.00 sec)
查看授權路徑。
2.禁用secure-file-priv可通過修改配置文件生效。
再試
mysql> select * from timer_gps_posinfo where time>'2017-01-01 00:00' and time <'2017-01-02 00:00' into outfile '/var/lib/mysql-files/posinfo.txt' fields terminated by ','; Query OK, 4532130 rows affected (16.18 sec)
成功導出,用時16秒。
同一臺機器,起了個docker-mysql,在新mysql中建立空數據庫和表結
使用
mysql> load data infile '/var/lib/mysql-files/posinfo.txt' into table timer_gps_posinfo fields terminated by ','; Query OK, 4532130 rows affected (17.28 sec) Records: 4532130 Deleted: 0 Skipped: 0 Warnings: 0
導入完成。