MySQL 进入输出文件 [英] MySQL into outfiles

查看:57
本文介绍了MySQL 进入输出文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我无法将 mySQL 查询结果导出到特定文件夹中的文件.这是我所做的:

I have trouble exporting a mySQL query result to a file in a specific folder. Here is what I did:

SELECT N1_Name,V_Name,N2_Name INTO OUTFILE '/home/user/Documents/result.csv' 
FIELDS TERMINATED BY ',' OPTIONALLY ENCLOSED BY '"' 
ESCAPED BY '\\' LINES TERMINATED BY '\n' 
FROM Result;  

我总是收到ERROR 1 (HY000): Can't create/write to file '/home/tle/Documents/PTQL_result.csv' (Errcode: 13)",这是权限被拒绝错误.
如果我使用默认位置或 tmp,则查询有效.
我什至 chmod 文件到 777 但 mysql 进程仍然无法写入它.
非常感谢任何想法.
谢谢

I always get "ERROR 1 (HY000): Can't create/write to file '/home/tle/Documents/PTQL_result.csv' (Errcode: 13)", which is permission denied error.
The query works if I use the default location or tmp.
I even chmod Documents to 777 but the mysql process still could not write to it.
Any ideas is greatly appreciated.
Thanks

推荐答案

该文件将由 mysql 用户创建,因此 mysql 用户需要对该目录具有写权限.听起来您已授予该权限.

The file will be create by the mysql user, so the mysql user needs write permission on the directory. It sounds like you've granted that permission.

mysql 用户还需要对上级目录有执行权限,特别是这个:

The mysql user also needs execute permission on the higher-level directories, specifically this one:

/home/tle

我猜 mysql 用户对该目录没有执行权限.如果您授予该权限,它应该可以工作.

I'm guessing the mysql user does not have execute permission on that directory. If you grant that permission it should work.

这篇关于MySQL 进入输出文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆