ERROR权限使用SELECT INTO FILE ...在MySQL
我试图执行SELECT INTO OUTFILE,我有以下错误ERROR权限使用SELECT INTO FILE ...在MySQL
我的要求:
SELECT * INTO OUTFILE '/local/home/datawords/upload/inscrit_newsletter_us.csv'
FIELDS TERMINATED BY ',' OPTIONALLY ENCLOSED BY '"'
LINES TERMINATED BY '\n'
FROM newsletter_us;
错误:
ERROR 1 (HY000): Can't create/write to file '/local/home/datawords/upload/exports/inscrit_newsletter_us.csv' (Errcode: 2)
exports目录的权限设置为0777.
您可以在如果有root权限的/ tmp文件夹
对于离select * into OUTFILE /tmp/inscrit_newsletter_us.csv
如果你不拥有的/ tmp文件夹根目录权限手段,请按照下面的步骤
sudo chown root:root /tmp
sudo chmod 1777 /tmp
sudo /etc/init.d/mysqld restart
谢谢。文件已创建。我无法在grapical模式下通过winscp查看它! – Mamadou 2012-02-22 13:32:53
The
FILE
privilege gives you permission to read and write files on the server host using theLOAD DATA INFILE
andSELECT ... INTO OUTFILE
statements and theLOAD_FILE()
function. A user who has theFILE
privilege can read any file on the server host that is either world-readable or readable by the MySQL server. (This implies the user can read any file in any database directory, because the server can access any of those files.) TheFILE
privilege also enables the user to create new files in any directory where the MySQL server has write access. As a security measure, the server will not overwrite existing files.
确保您的用户具有该特权。
然后检查目标目录权限是否符合上述要求。
我敢打赌,你有'AppArmour'或'SELinux'运行。尝试导出到MySQL数据目录 - 如果这有效,这应该是证明。 – 2012-02-22 10:38:57
研究努力失败 – 2012-02-22 11:35:42