MySQL导出导入CSV数据
程序员文章站
2024-02-11 11:49:04
...
前提条件:
[mysql] 9> show variables like "%secu%";
+------------------+-----------------------+
| Variable_name | Value |
+------------------+-----------------------+
| secure_auth | ON |
| secure_file_priv | /var/lib/mysql-files/ |
+------------------+-----------------------+
2 rows in set (0.00 sec)
[mysql] 10>
MySQL导入CSV数据:
load data local infile '/home/test.csv' into table test character set utf8mb4 fields terminated by ',' (number,name,gender,birthday,age,mobile,qq,insert_date);
MySQL导出数据到CSV:
select name,scene_id,type,version,data,ip,ctime from test into outfile "/var/lib/mysql-files/test.csv" fields terminated by ',';
利用mysqldump命令导出CSV文件
mysqldump -uroot -p -t -T /var/lib/mysql-files/ mydb mytable --fields-terminated-by=','