-----
1.Linux
导出命令1:带标题行
mysql -uroot -proot123 -e 'select user, host, plugin from mysql.user;' | sed -e 's/\t/,/g'
---
mysql -uroot -proot123 -e 'select user, host, plugin from mysql.user;' | sed -e 's/\t/,/g' > ./user.csv
导出命令2:导出数据不带标题行(-N 不导出标题行)
mysql -uroot -proot123 -N -e 'select user, host, plugin from mysql.user;' | sed -e 's/\t/,/g'
运行效果
2.通用方法(windwos Linux)
select * from test_info
into outfile '/tmp/user.csv'
fields terminated by ',' --字段间以,号分隔
optionally enclosed by '"' --字段用"号括起
escaped by '"' --字段中使用的转义符为"
lines terminated by '\n'; --行以\n结束
3.扩展知识
■导入数据
https://blog.csdn.net/sxzlc/article/details/116106444
■sed命令
https://blog.csdn.net/sxzlc/article/details/115304968
---