Mysql query result output to the file method, mysql Query Result
Export/output/Write mysql query results to a file
Method 1:
Run the following command:
Mysql> select count (1) from table into outfile '/tmp/test.xls ';
Query OK, 31 rows affected (0.00 sec)
Upload the file test.xls under/tmp /.
Problems:
Mysql> select count (1) from table into outfile '/data/test.xls ';
Error:
ERROR 1 (HY000): Can't create/write to file '/data/test.xls' (Errcode: 13)
Possible cause: mysql has no permission to write data to/data /.
Method 2:
All queries are automatically written to files:
Mysql> pager cat>/tmp/test.txt;
PAGER set to 'cat>/tmp/test.txt'
All subsequent query results are automatically written to/tmp/test.txt 'and overwritten
Mysql> select * from table;
30 rows in set (0.59 sec)
No query results are displayed in the box
Method 3:
Jump out of mysql Command Line
[Root @ SHNHDX63-146 ~] # Mysql-h 127.0.0.1-u root-p XXXX-P 3306-e "select * from table">/tmp/test/txt
The above is all the methods for outputting mysql query results to files provided by xiaobian. I hope you can provide more support ~