select * from actor into outfile '/data/actor.text' fields terminated by "," enclosed by '"';
第一列是数值型,两边不加引号,则改为:
select * from actor into outfile '/data/actor1.text' fields terminated by "," optionally enclosed by '"';
导出不加引号,改为:
select * from actor into outfile '/data/actor2.text' fields terminated by "," optionally enclosed by '';
或
select * from actor into outfile '/data/actor3.text' fields terminated by "," ;
注意:
当导出命令中包含字段引用符时,数据中含有转义字符本身和字段引用符的字符需要被转义。
当导出命令中不包含字段引用符时,数据中含有转义字符本身和字段分割符的字符需要被转义。
select ... into outfile 产生的输出文件如果在目标目录下有重名文件,将不会创建成功,源文件不能被自动覆盖。
使用mysqldump导出:
mysql/bin> ./mysqldump -uroot -p -T /data sakila actor --fields-terminated-by ',';