导出数据库表中的某一列或者多列数据的方法:
select f1, f2 from tbname into outfile '/tmp/outfilename.txt';
有可能出现以下错误:
mysql> select distinct account from logs_2016_02_29 into outfile '/home/ztx/PARKOUR/account.txt';
ERROR 1086 (HY000): File '/home/ztx/PARKOUR/account.txt' already exists
此错误是说目标文件已经存在,为了保证原来的文件不被覆盖,因为account.txt文件里面可能包含有重要信息,
为了防止意外被覆盖,所以报错;
ERROR 1 (HY000): Can't create/write to file '/home/ztx/PARKOUR/account1.txt' (Errcode: 13)
次错误是说权限不够;
Query OK, 1827 rows affected (0.06 sec)
查询成功,可以在/tmp/account1.txt文件中看到导出的account这一列的数据