解決:CentOS下MySQL執行select ... into outfile ...: Can't create/write to file '...' (Errcode: 13)
阿新 • • 發佈:2018-12-26
原因:selinux阻止寫入操作
解決:vi /etc/selinux/config
將:SELINUX=enforcing 改為 SELINUX=disabled# This file controls the state of SELinux on the system. # SELINUX= can take one of these three values: # enforcing - SELinux security policy is enforced. # permissive - SELinux prints warnings instead of enforcing. # disabled - No SELinux policy is loaded. SELINUX=enforcing # SELINUXTYPE= can take one of these two values: # targeted - Targeted processes are protected, # mls - Multi Level Security protection. SELINUXTYPE=targeted
SELINUX=enforcing 改為 SELINUX=disabled
儲存並且重啟伺服器:reboot
再次執行命令:select ... into outfile ...
則執行成功:Query OK, 0 rows affected
注:關閉selinux可能會帶來安全問題暫時還沒有深入研究(建議操作完成後,改回配置檔案)