1.SELECT INTO OUTFIL:
这种方法不能覆盖或者追加到已经存在的文件,只能写入到新文件,并且建立文件的路径需要mysql进程用户有权限建立新文件。
mysql 61571 60876 15 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(root@localhost:tiger_erp)>select * from QQLH_CODE into 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(root@localhost:tiger_erp)>select * from QQLH_CODE into outfile "/home/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(root@localhost:tiger_erp)>select * from QQLH_CODE into outfile "/home/mysql/QQLH_CODE_252.sql";
2.巧用pager重定向stdout
mysql(root@localhost:tiger_erp)>pager cat >/home/wy/mysql/QQLH_CODE.sql;
PAGER set to ‘cat >/home/wy/mysql/QQLH_CODE.sql‘
mysql(root@localhost:tiger_erp)>select * from QQLH_CODE;
6250 rows in set (0.04 sec)
mysql(root@localhost:tiger_erp)>nopager;
PAGER set to ‘cat >/home/wy/mysql/QQLH_CODE.sql‘
mysql(root@localhost:tiger_erp)>select * from QQLH_CODE;
6250 rows in set (0.04 sec)
mysql(root@localhost:tiger_erp)>nopager;