Home > Database > Mysql Tutorial > body text

Why Does LOAD DATA INFILE Fail with MySQL Error Code 13?

Susan Sarandon
Release: 2024-11-06 05:52:03
Original
666 people have browsed it

Why Does LOAD DATA INFILE Fail with MySQL Error Code 13?

Troubleshoot MySQL Error Code 13: LOAD DATA INFILE Problems

Database administrators may encounter MySQL Error Code 13 when executing LOAD DATA INFILE statements. This error typically occurs when MySQL cannot access the specified file.

Problem:
A user reports an Error Code 13 when attempting to load data from a remote file into a table using the LOAD DATA INFILE query. The database user has all necessary privileges, and the file and folder permissions are set to chmod 777 (rwxrwxrwx).

Solution:
The solution to this issue lies in the Apparmor program, which exists particularly in Ubuntu systems. Apparmor prevents MySQL from accessing files in certain directories by default. To enable MySQL to read files from the "tmp" directory, follow these steps:

  1. Open the /etc/apparmor.d/usr.sbin.mysqld file using a text editor, e.g., sudo vim /etc/apparmor.d/usr.sbin.mysqld.
  2. Add the line /tmp/** rwk to the file, ensuring it's properly placed within the allowed directories section.
  3. Reload Apparmor using the command sudo /etc/init.d/apparmor reload.

After completing these modifications, MySQL should be able to successfully execute the LOAD DATA INFILE query without encountering Error Code 13.

The above is the detailed content of Why Does LOAD DATA INFILE Fail with MySQL Error Code 13?. For more information, please follow other related articles on the PHP Chinese website!

source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Latest Articles by Author
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template