Permissions for mysql to export data to a file
Question:
Mysql > select * from products into outfile "/ dbbak/outfile.txt" Fields terminated by "|" Lines terminated by "\ n"
ERROR 1 (HY000): Can't create/write to file'/ dbbak/outfile.txt' (Errcode: 13)
Solve
In the linux of the red hat series, there are restrictions on what daemon can be operated on by selinux, and the select into outfile command of mysql is the daemon of mysql to write the file. Of course, you must have permission to write a file before writing a file. Selinux restricts this permission. If selinux is closed, there is no problem with the execution of this command.
1. Close selinux
Temporary: setenforce 0
Permanent: # vim / etc/sysconfig/selinux
SELINUX=disable
2. Selinux gives the daemon permission to mysql separately.
# getsebool-a view the current permissions on a series of daemons on the system