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

- **ID:** `database/mysql-data-directory-permission`
- **领域:** database
- **类别:** system_error
- **错误码:** `1017`
- **验证级别:** ai_generated
- **修复率:** 88%

## 根因

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

## 版本兼容性

| 版本 | 状态 | 引入 | 弃用 |
|------|------|------|------|
| MySQL 8.0.x | active | — | — |
| MySQL 5.7.x | active | — | — |
| MariaDB 10.x | active | — | — |

## 解决方案

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
   ```

## 无效尝试

- **Running chmod 777 on the .ibd file** — Excessive permissions can cause security issues and MySQL may still fail if the parent directory permissions are wrong; also not a sustainable fix. (70% 失败率)
- **Restarting MySQL without fixing permissions** — Restarting does not change file permissions; the error will reappear on the next access. (95% 失败率)
