一叶知秋.

业精于勤,荒于嬉;行成于思,毁于随。

ERROR 1 (HY000): Can't create/write to file '/data/mysql/app.txt' (Errcode: 13)

环境:
CentOS6.0 64位
MySQL5.5.48

问题:

#使用'select into outfile'备份数据表提示无法写入文件
mysql> select * from s_app_home_nav into outfile '/data/mysql/app.txt';
ERROR 1 (HY000): Can't create/write to file '/data/mysql/app.txt' (Errcode: 13)

排查:

#查看mysql的进程用户,为mysql用户
[root@lfs ~]# ps aux|grep mysqld 
root       1400  0.0  0.1 108208  1612 ?        S    01:22   0:00 /bin/sh /usr/local/mysql/bin/mysqld_safe --user=mysql
mysql      1778  0.0  6.6 974276 67076 ?        Sl   01:22   0:06 /usr/local/mysql/bin/mysqld --basedir=/usr/local/mysql --datadir=/usr/local/mysql/data --plugin-dir=/usr/local/mysql/lib/plugin --user=mysql --log-error=/usr/local/mysql/data/lfs.err --pid-file=/usr/local/mysql/data/lfs.pid --socket=/tmp/mysql.sock --port=3306
#查看/data/mysql目录的权限,mysql用户没有写入权限
[root@lfs ~]# ls -ld /data/mysql/
drwxr-xr-x 4 root root 4096 Aug 23 17:03 /data/mysql/

解决办法:

#将/data/mysql/目录的归属为mysql用户
chown -R mysql.mysql /data/mysql/

[root@lfs ~]# ls -ld /data/mysql/              
drwxr-xr-x 4 mysql mysql 4096 Aug 23 17:03 /data/mysql/

验证:

mysql> select * from s_app_home_nav into outfile '/data/mysql/app.txt';
Query OK, 24 rows affected (0.06 sec)
posted @ 2020-08-25 18:19  ccku  阅读(1204)  评论(0编辑  收藏  举报