解决:CentOS下MySQL执行select ... into outfile ...: Can't create/write to file '...' (Errcode: 13)

时间:2021-10-09 21:12:17

原因:selinux阻止写入操作

解决:vi /etc/selinux/config

# 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
SELINUX=enforcing 改为 SELINUX=disabled

保存并且重启服务器:reboot

再次执行命令:select ...  into outfile ...

则执行成功:Query OK, 0 rows affected


注:关闭selinux可能会带来安全问题暂时还没有深入研究(建议操作完成后,改回配置文件)