Mysql 通过 PHP 给出 "Can' t create/write to file"错误

标签 mysql file-io

完整的错误是:

Message: Mysqli statement execute error : Can't create/write to file '/var/www/zendApp/backup/mysql/1268733580_name.sql' (Errcode: 13)

我已经在/var/www/ZendApp/backup/mysql 目录中尝试了一些操作

$chmod 777 mysql
$chmod 1777 mysql
$chown root:root mysql
$chown mysql:mysql mysql

但没有任何帮助。我在这里做错了什么?我是否必须在某个地方告诉 mysql 我可以写入该目录?

最佳答案

在 Dominik @ Super User 的帮助下,我发现 Ubuntu 正在运行 apparmor 并且我的服务器也在 Ubuntu 上运行。我引用维基百科:

AppArmor allows the system administrator to associate with each program a security profile that restricts the capabilities of that program

果然,这些程序中就有 mysqld。因此,问题不是用户或其权限,而是 apparmor 对进程施加的限制。然后我找到了解决方案 here

sudo touch /etc/apparmod.d/disable/usr.sbin.mysqld
sudo /etc/init.d/apparmor reload

这使得 mysqld 成为一个自由进程,对于我来说,在该服务器上,没有问题。所以,经过几天的搜索,问题解决了!

关于Mysql 通过 PHP 给出 "Can' t create/write to file"错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2453468/

相关文章:

java - FileInputStream 逐字节或 block 读取?

linux - 从文件 Bash 添加整数

mysql - 当唯一的变化是这种情况时,如何强制mysql更新

mysql - 查询月份等于的数据库

php - 有没有人发现 REGEX "\b"在 MYSQL 中不起作用?

php - 我可以替换ajax中的php代码而不是url :

c - `Build Error` 错误 -1073741819 - C

c - 使用 truss 调试 open() 命令调用

c++ - 以二进制序列化和反序列化 vector

php - 插入的数据不会进入 phpMyAdmin 数据库