1017 database system_error ai_generated true

错误 1017 (HY000):找不到文件:'./mydb/tables.ibd'(错误号:13 - 权限被拒绝)

ERROR 1017 (HY000): Can't find file: './mydb/tables.ibd' (errno: 13 - Permission denied)

ID: database/mysql-data-directory-permission

其他格式: JSON · Markdown 中文 · English
88%修复率
88%置信度
1证据数
2023-07-10首次发现

版本兼容性

版本状态引入弃用备注
MySQL 8.0.x active
MySQL 5.7.x active
MariaDB 10.x active

根因分析

MySQL 服务器进程由于数据目录上的文件权限或所有权不正确,无法读取或写入 .ibd 文件。

English

The MySQL server process cannot read or write the .ibd file due to incorrect file permissions or ownership on the data directory.

generic

官方文档

https://dev.mysql.com/doc/refman/8.0/en/data-directory.html

解决方案

  1. 修复所有权:chown mysql:mysql /var/lib/mysql/mydb/tables.ibd;然后确保父目录权限正确:chmod 750 /var/lib/mysql/mydb
  2. 如果使用 AppArmor 或 SELinux,检查和更新策略:ausearch -m avc -ts recent;然后 restorecon -R /var/lib/mysql

无效尝试

常见但无效的做法:

  1. Running chmod 777 on the .ibd file 70% 失败

    Excessive permissions can cause security issues and MySQL may still fail if the parent directory permissions are wrong; also not a sustainable fix.

  2. Restarting MySQL without fixing permissions 95% 失败

    Restarting does not change file permissions; the error will reappear on the next access.