INTO OUTFILE, LOAD DATA INFILE
mysql> select * from test into outfile '/tmp/1.txt';
Query OK, 1000000 rows affected (0.65 sec)
mysql> truncate table test;
Query OK, 0 rows affected (0.00 sec)
mysql> load data infile '/tmp/1.txt' into table test;
Query OK, 1000000 rows affected (6.50 sec)
Records: 1000000 Deleted: 0 Skipped: 0 Warnings: 0
mysql> select count(*) from test;
+----------+
| count(*) |
+----------+
| 1000000 |
+----------+
1 row in set (0.32 sec)
导出为有格式的CSV文件
mysql> select * from test into outfile '/tmp/1.csv' fields enclosed by '"' terminated by ',' lines terminated by '\r\n';
Query OK, 1000000 rows affected (0.61 sec)