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)
作者:ccku
本文版权归作者和博客园共有,欢迎转载,但未经作者同意必须保留此段声明,且在文章页面明显位置给出原文连接,否则保留追究法律责任的权利。如有问题或建议,请多多赐教,非常感谢。