LOAD DATA INFILE Error Code 13: Unable to Access Remote File
When executing a LOAD DATA INFILE query, MySQL users may encounter Error Code 13 due to permission issues or apparmor restrictions.
Identifying the Root Cause
Despite granting full privileges to the database user and setting file/folder permissions to 777, the error persists. This issue likely stems from apparmor, a program in Ubuntu that hinders MySQL's file access.
Resolving the Issue
Edit the Apparmor Configuration:
Open the apparmor configuration file: sudo vim /etc/apparmor.d/usr.sbin.mysqld.
Add File Directory:
Add the following line to the configuration file: /tmp/** rwk. This grants MySQL read, write, and execute permissions to the "/tmp" directory.
Reload Apparmor:
Restart apparmor with: sudo /etc/init.d/apparmor reload.
Additional Notes
Note that the directory added to the configuration file may vary depending on the location of the file used in the LOAD DATA INFILE query. It is also recommended to use a specific subdirectory rather than granting access to the entire "/tmp" directory.
The above is the detailed content of Why Is MySQL Throwing Error Code 13: Unable to Access Remote File?. For more information, please follow other related articles on the PHP Chinese website!