简体   繁体   English

PHPMyAdmin(错误代码:13-权限被拒绝)

[英]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. 在phpmyadmin中运行查询以从htdocs中的文件加载数据时,出现权限错误,我正在使用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 我尝试将article.csv的用户更改为守护程序,因为这是用户apache在

 $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. 编辑:能够通过左键单击文件,然后单击getInfo,然后将“所有人”的权限从“无权访问”更改为“只读”来使其运行查询。 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. 对于Linux和Mac OS,该文件需要具有读取权限。 On Windows, these don't generally matter. 在Windows上,这些通常无关紧要。

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. 如果您已将文件从另一个文件夹(例如CD上)中移出或从使用FAT / NTFS的笔驱动器中获取,则您将没有Linux / Mac读取权限。 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. 例如,除非您授予其权限,否则任何Web文件夹中的php都将无法访问您的文件。

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. 授予整个文件夹权限的方法不止一种,但是目前在Linux上执行chmod或在Mac上执行等效操作可以解决此问题。 Sorry I don't know the exact Mac command. 抱歉,我不知道确切的Mac命令。

Alternatively, on Ubuntu, you can open the file manager (Nautilus) with admin priveleges just to set the file's permissions. 另外,在Ubuntu上,您可以使用admin特权打开文件管理器(Nautilus)来设置文件的权限。 I guess you have a tool like this on Mac too. 我想您在Mac上也有类似的工具。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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