赞
踩
MySQL SELECT statement allowed us to pipe the query result in to a file via SELECT ... INTO OUTFILE. It work just fine for me most of the time, until recently I hit this error:
ERROR 1 (HY000) at line 1: Can't create/write to file '\home\myuser\my_output_file.txt' (Errcode: 2) mv: cannot stat `/home/myuser/my_output_file.txt': No such file or directoryThe first thing come to my mind is the problem of file permission, so I grant 777 permission to my output directory. But the problem still exist.
The SELECT ... INTO OUTFILE 'file_name' form of SELECT writes the selected rows to a file. The file is created on the server host, so you must have the FILE privilege to use this syntax.And the keyword is " server host". I made wrong assumption that it will write file to the server that execute the SELECT ... INTO OUTFILE.
mysql -u myuser -ppassword -h remotehost mydb < myquery.sql > my_output_file.txtReading documentation is bored but important :P
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。