| 代碼 | 訊息 | 常見原因 |
|---|---|---|
| 1005 | Can't create table | 外鍵定義錯誤、磁碟滿、權限不足 |
| 1006 | Can't create database | 權限、磁碟、路徑問題 |
| 1007 | Database exists | 重複建庫 |
| 1008 | Database doesn't exist | 刪除/使用不存在的庫 |
| 1049 | Unknown database | 拼寫錯誤、未建立 |
| 1050 | Table already exists | 重複建表 |
| 1051 | Unknown table | 表不存在 |
| 代碼 | 訊息 | 處理方向 |
|---|---|---|
| 1044 | Access denied for user | GRANT 權限、host 匹配 |
| 1045 | Access denied (password) | 密碼錯誤、plugin 不匹配 |
| 1130 | Host not allowed to connect | 修改 user.Host、防火牆、skip-name-resolve |
| 1133 | User doesn't exist | 建立用戶或檢查拼寫 |
| 1227 | Access denied; need SUPER | 授予 SUPER 或降低操作需求 |
| 代碼 | 訊息 | 解決 |
|---|---|---|
| 1022 / 1062 / 1169 | Duplicate entry for key | 主鍵/唯一鍵衝突,檢查資料或用 IGNORE/REPLACE/ON DUPLICATE KEY UPDATE |
| 1216 | Foreign key constraint fails (child) | 子表插入的外鍵值在主表不存在 |
| 1217 | Foreign key constraint fails (parent) | 主表刪除/修改被引用的記錄 |
| 代碼 | 訊息 | 調優方向 |
|---|---|---|
| 1021 | Disk full | 清理空間、擴容、檢查 tmpdir |
| 1037/1041 | Out of memory | 調小緩衝區、增加記憶體、檢查洩漏 |
| 1038 | Sort buffer too small | 增大 sort_buffer_size |
| 1040/1203 | Too many connections | 增大 max_connections、連線池、修復洩漏 |
| 1114 | Table is full | MyISAM 檔案大小限制、InnoDB 表空間滿、磁碟滿 |
| 1226 | User resource limit exceeded | 調整 max_user_connections 等資源限制 |
net_read_timeout/net_write_timeout、優化慢查詢innodb_lock_wait_timeout、優化長事務、索引SHOW ENGINE INNODB STATUS、錯誤日誌、慢查詢日誌