Solving mysql Errcode 13 permissions errors and Select into Outfile statements
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
<code>/usr/sbin/mysqld { ... **/data/ r, /data/* rw,** }</code>
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
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!