Home > Database > Mysql Tutorial > How to Fix MySQL Errcode 13 (Permissions Error) with SELECT INTO OUTFILE?

How to Fix MySQL Errcode 13 (Permissions Error) with SELECT INTO OUTFILE?

Linda Hamilton
Release: 2025-01-24 14:52:10
Original
769 people have browsed it

How to Fix MySQL Errcode 13 (Permissions Error) with SELECT INTO OUTFILE?

Solving mysql Errcode 13 permissions errors and Select into Outfile statements

Question:

When trying to use Select Into Outfile to export the table data to the CSV file outside the server's default directory, even if the authority and ownership are adjusted, Errcode 13 will still be encountered. This often appears on the Ubuntu system, especially on the system running Apparmor.

Solution:

<.> 1. Check the status of the apparmor:

execute the command to verify whether mysqld is in the mandatory mode. If it appears in the list, Apparmor is likely to prevent writing. <.> 2. Edit the apparmor configuration file:

sudo aa-status Open the file and add the required directory path to the bottom of the file to ensure that there is read/write permissions. For example:

<.> 3. Re -load the apparmor configuration file:

execute command to apply changes. /etc/apparmor.d/usr.sbin.mysqld

<.> 4. Try to query again:
<code>/usr/sbin/mysqld {
    ...
    **/data/ r,
    /data/* rw,**
}</code>
Copy after login

Re -load the AppArmor configuration file, try the Select into Outfile query again. MySQL should now be able to write to the target directory.

Warning:

sudo /etc/init.d/apparmor reload

Pay attention to the hidden dangers of the security hazard of the directory outside the default position to the authorization of mysql to the default position. Ensure that appropriate measures have been taken to protect sensitive data.

The above is the detailed content of How to Fix MySQL Errcode 13 (Permissions Error) with SELECT INTO OUTFILE?. 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