select * from test into outfile '/home/user/test.txt' 在linux(centos)下 ,启动了mysql 并给用户文件读写的权利 grant file on *.* to root@localhost; 在linux系统上,目录的权限全部是 rwxrwxrwx
在mysql下输入 select * from test into outfile '/home/user/test.txt' 出现错误信息:
ERROR 1 (HY000): Can't create/write to file '/home/user/test.txt' (Errcode: 13)
当时如果是tmp目录的话就不会有这个错误
1 2
select * from test into outfile '/tmp/test.txt' Query OK, 0 rows test(0.00 sec)
难道只能是tmp目录吗? 有什么地方可以修改的吗?
后来把home的所有者改成了mysql
1 2 3
drwxrwxrwx 5 mysql mysql 4096 Sep 4 10:08 home select * from test into outfile '/home/test.txt' ERROR 1 (HY000): Can't create/write to file '/home/test.txt' (Errcode: 13)
[root@localhost /]# ls -l drwxrwxrwx 4 root root 4096 9月 4 21:03 home drwxrwxrwt 10 root root 4096 9月 4 21:03 tmp [root@localhost /]# mysql Welcome to the MySQL monitor. Commands end with ; or \g. Your MySQL connection id is 27 Server version: 5.1.14-beta MySQL Community Server (GPL) Type 'help;' or '\h' for help. Type '\c' to clear the buffer. mysql> use mysql; Reading table information for completion of table and column names You can turn off this feature to get a quicker startup with -A Database changed mysql> select user from user; +--------+ | user | +--------+ | system | | root | +--------+ 2 rows in set (0.03 sec) mysql> select user from user into outfile '/home/test.txt'; Query OK, 2 rows affected (0.02 sec) [root@localhost home]# ls -l -rw-rw-rw- 1 mysql mysql 12 9月 4 21:12 test.txt [root@localhost home]# cat /home/test.txt system root select * from test into outfile '/home/test.txt' ERROR 1 (HY000): Can't create/write to file '/home/test.txt' (Errcode: 13)
select * from test into outfile '/home/user/test.txt'` select * from test into outfile '/home/user/test.txt'该语句产生的文件是 -rw-rw-rw- 1 mysql mysql 12 9月 4 21:12 test.txt
shell>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 - SELinux is fully disabled. SELINUX=enforcing
shell>getsebool -a可以查看当前的对系统一系列守护进程的权限情况。 lpd_disable_trans --> off mail_read_content --> off mailman_mail_disable_trans --> off mdadm_disable_trans --> off mozilla_read_content --> off mysqld_disable_trans --> off nagios_disable_trans --> off named_disable_trans --> off named_write_master_zones --> off nfs_export_all_ro --> on nfs_export_all_rw --> on nfsd_disable_trans --> off nmbd_disable_trans --> off nrpe_disable_trans --> off shell>setsebool -P mysqld_disable_trans=1 开启对mysql守护进程的权限,这样 mysql> select user from user into outfile '/home/test.txt';