简体   繁体   中英

PHPMyAdmin (Errcode: 13 - Permission denied)

I'm getting a permissions error when running a query in phpmyadmin to load data from a file in htdocs, I'm using XAMPP.
This is the query:

LOAD DATA INFILE '/Applications/XAMPP/htdocs/article.csv'
INTO TABLE Article
FIELDS TERMINATED BY ','
LINES TERMINATED BY '\n'

this is the error message:

29 - File '/Applications/XAMPP/xamppfiles/htdocs/article.csv' not found (Errcode: 13 - Permission denied) 

I tried changing the user of article.csv to be daemon since this is the user apache runs under

 $sudo chown daemon article.csv
$ls -l
-rw-r-----@  1 daemon            staff   24117248 Dec  6 23:35 article.csv

but I'm still getting the error,

EDIT: was able to get it to run the query by left click on file, then getInfo, then change permission of Everyone from No Access to Read Only. This is an ok solution since I only need to run the query one time to load the data.

This is clearly a permissions issue like I stated in my comments.

For Linux and Mac OSs, the file needs to have READ permissions. On Windows, these don't generally matter.

If you had moved your file from another folder (eg: on CD) or got it from a pen drive that uses FAT/NTFS you will not have the Linux/Mac read permissions. Of course this issue is only when you put the file into a folder that has special privileges. For example, your file will be inaccessible by php in any web folder unless you give it the permission.

There is more than one way to give permissions to an entire folder but for the moment doing a chmod on Linux or the equivalent on the Mac should solve the issue. Sorry I don't know the exact Mac command.

Alternatively, on Ubuntu, you can open the file manager (Nautilus) with admin priveleges just to set the file's permissions. I guess you have a tool like this on Mac too.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM