1.SELECT into Outfil:This method can not overwrite or append to the existing file, can only write to the new file, and establish the path of the file requires the MySQL process user has permission to create a new file. MySQL 61571 60876 Aug27? 3-10:58:08/usr/local/mysql/bin/mysqld--basedir=/usr/local/mysql--datadir=/data/ Mysqldata/data--plugin-dir=/usr/local/mysql/lib/plugin--user=mysql--log-error=/data/mysqldata/data/ Localhost.localdomain.err--pid-file=/data/mysqldata/data/localhost.localdomain.pid--socket=/data/mysqldata/ Mysql.sock--port=33096 MySQL ([email protected]: TIGER_ERP) >select * from Qqlh_code to outfile "/home/wy/mysql/qqlh_code_252.sql "
;
ERROR 1 (HY000): Can ' t create/write to file '/home/wy/mysql/qqlh_code_252.sql ' (Errcode:13-permission denied)
MySQL ([email protected]: TIGER_ERP) >select * from Qqlh_code to outfile "/home/mysql/qqlh_code_252.sql"; 2. Skillfully use pager redirect stdoutMySQL ([email protected]: TIGER_ERP) >pager cat >/home/wy/mysql/QQLH_CODE.sql;
PAGER set to ' Cat >/home/wy/mysql/qqlh_code.sql '
MySQL ([email protected]: TIGER_ERP) >select * from Qqlh_code;
6250 rows in Set (0.04 sec)
MySQL ([email protected]: tiger_erp) >nopager;
2 ways MySQL writes query results to a file