SELECT ... INTO OUTFILE报错ERROR 1 (HY000) at line 1: Can't create/write to file...
来源:互联网 发布:自建域名服务器 编辑:程序博客网 时间:2024/05/29 13:36
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.
Then I check the Mysql username I use, and found that it was granted with FILE permission correctly.
Then I start to google on this error code, and most of the search result point to similars causes.
So I read again the documentation of MySQL, and I found this:
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.
And the workaround is simple, just change my SELECT statement by remove the OUTFILE portion. And pipe the query to file from the MySQL command line
mysql -u myuser -ppassword -h remotehost mydb < myquery.sql > my_output_file.txtReading documentation is bored but important :P
- SELECT ... INTO OUTFILE报错ERROR 1 (HY000) at line 1: Can't create/write to file...
- MySQL into outfile 问题解决:ERROR 1 (HY000): Can't create/write to file
- mysql into outfile ERROR : Can't create/write to file
- Mysql ERROR 1 (HY000): Can't create/write to file
- 解决:CentOS下MySQL执行select ... into outfile ...: Can't create/write to file '...' (Errcode: 13)
- 解决“Error 1(HY000): Can't create/write file”问题
- CentOS 下 MySQL运行 select* from xxx into outfile : Can't create/write to file xxx (Errcode: 13)
- ERROR 1 (HY000): Can't create/write to file '/test.txt' (Errcode: 13)
- ERROR 1 (HY000): Can't create/write to file'/' (Errcode: 13)错误解决
- mysql> desc tablename; ERROR 1 (HY000): Can't create/write to file '/tmp/#sql_909_0.MYI'
- ERROR 1 (HY000): Can't create/write to file'/' (Errcode: 13)错误解决
- ERROR 1 (HY000): Can't create/write to file'/' (Errcode: 13)错误解决
- 解决Mysql ERROR 1 (HY000): Can't create/write to file 问题
- ERROR 1 (HY000): Can't create/write to file '/myload/user6.txt' (Errcode: 13
- mysqldump: Got error: 1: Can't create/write to file '/data/export/test.txt' (Errcode: 13)
- mysqldump: Got error: 1: Can't create/write to file (Errcode: 13
- 关于MYSQL Error:ERROR 1005 (HY000) at line 3: Can't create table '.\xx.frm'错误
- ERROR 1005 (HY000) at line 372: Can't create table './xxx.frm' (errno: 150)
- 1
- WebLogic Server 性能优化 (2) JDBC连接池篇
- 调研分享:Flipboard的使用特点和页面信息抽取机制
- WebLogic Server 性能优化 (3) 应用篇
- 正式进入IT业
- SELECT ... INTO OUTFILE报错ERROR 1 (HY000) at line 1: Can't create/write to file...
- WebLogic Server 性能优化 (4) JMS篇
- Store.JS文件 手动加载数据
- Android中shape的使用
- 在同一 IIS 进程中不可能运行两个不同的 ASP.NET 版本。请使用 IIS 管理工...
- html中form表单的使用实例
- ViewState对象序列化
- Android线程操作AsyncTask的用法
- 查看数据库对象