mysql查询结果导出到文件

mysql> select 1 into outfile '/tmp/t1.txt';
Query OK, 1 row affected (0.00 sec)
mysql> select 1 into outfile '/tmp/t1.txt';
ERROR 1086 (HY000): File '/tmp/t1.txt' already exists

另外一种方法:
mysql> pager cat > /tmp/t1.txt
PAGER set to 'cat > /tmp/t1.txt'
mysql> select 1;
1 row in set (0.00 sec)#注意不会再显示结果,已经输出到文件

关闭pager,退出重新登陆mysql


你可能感兴趣的:(mysql,查询结果导出到文件)