(Errcode: 13) when executing 'SELECT INTO OUTFILE'

使用mysqldump工具导出数据时,提示下面错误

[root@localhost bin]# mysqldump -uroot -proot test student -T /bak
mysqldump: Got error: 1: Can't create/write to file '/bak/student.txt' (Errcode: 13) when executing 'SELECT INTO OUTFILE'
[root@localhost bin]# ll /
total 626746
drwxr-xr-x   4 root   root          4096 Oct  5  2010 8350262
-rw-r--r--   1 root   root          2118 Nov 11  2013 SQL.sql
-rw-r--r--   1 root   root          1820 Aug  4 10:18 backup.sql
drwxr-xr-x   2 root   root          4096 Aug  4 10:49 bak

[root@localhost bin]# ./perror 13
OS error code  13:  Permission denied

但是不指定-T参数,却能成功导出

[root@localhost bin]# mysqldump -uroot -proot test student >/bak/backup.sql

[root@localhost bin]# ll /bak
total 12
-rw-r--r-- 1 root  root   313 Aug  4 10:36 backup.sql

网上搜索得知要把目标目录修改为mysql组所有

[root@localhost bin]# chown mysql:mysql /bak
[root@localhost bin]# mysqldump -uroot -proot test student -T /bak
[root@localhost bin]# ll /bak
total 12
-rw-r--r-- 1 root  root   313 Aug  4 10:36 backup.sql
-rw-r--r-- 1 root  root  1303 Aug  4 11:02 student.sql
-rw-rw-rw- 1 mysql mysql   13 Aug  4 11:02 student.txt

你可能感兴趣的:(mysql)