mysql踩過的坑

  1. ERROR 1146 (42S02): Table 'test.user' doesn't exist
    • 刪除用戶不存在
  2. ERROR 1215 (HY000): Cannot add foreign key constraint
    • 被關聯字段必須是至少是有unique約束的,沒有則報錯
  3. ERROR 1062 (23000): Duplicate entry '1' for key 'id'
    • unique約束,插入數據重複
  4. ERROR 1075 (42000): Incorrect table definition; there can be only one auto column and it must be defined as a key
    • auto_increment字段必須定義一個鍵(key),primary或unique
  5. ERROR 1452 (23000): Cannot add or update a child row: a foreign key constraint fails (test.test_1_1, CONSTRAINT fk_test_1 FOREIGN KEY (id) REFERENCES test_1 (id) ON DELETE SET NULL ON UPDATE CASCADE)
    • 被關聯的表中沒有數據
  6. ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'foreign key(teacher_id) references teacher(tid) on delete cascade on update cascade' at line 1
    • 別關聯的表中必須有數據才能夠關聯,不然會報錯
  7. ERROR 1022 (23000): Can't write; duplicate key in table '#sql-13ce_5'
    • 使用alter添加約束的名稱和已經存在的約束名稱相同
  8. ERROR 1364 (HY000): Field 'age' doesn't have a default value
    • age字段沒有默認值
  9. ERROR 1055 (42000): Expression #1 of SELECT list is not in GROUP BY clause and contains nonaggregated column 'day40.employee.id' which is not functionally dependent on columns in GROUP BY clause; this is incompatible with sql_mode=only_full_group_by
    • 必須有group的字段
  10. ERROR 1093 (HY000): You can't specify target table 'book' for update in FROM clause
  11. ERROR 1055 (42000): Expression #1 of SELECT list is not in GROUP BY clause and contains nonaggregated column 'day40.staff.id' which is not functionally dependent on columns in GROUP BY clause; this is incompatible with sql_mode=only_full_group_by
  12. ERROR 1242 (21000): Subquery returns more than 1 row
    • 子查詢返回值爲多個
  13. ERROR 1052 (23000): Column 'sid' in field list is ambiguous
    • sid字段位置模糊,通常須要給table命別名,或者使用具題table’s name指定便可
  14. ERROR 1248 (42000): Every derived table must have its own alias
    • 每一個初始表必須有一個別名
  15. ERROR 1630 (42000): FUNCTION t2.max does not exist. Check the 'Function Name Parsing and Resolution' section in the Reference Manual
    • 若是使用聚合函數獲得的值,須要手動指定名稱
  16. pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on '127.0.0.1' ([Errno 61] Connection refused)")
    • 經過socket鏈接mysql出錯,一般是默認參數和傳參出現問題
    • 默認端口號3306,能夠經過sudo lsof -i:3306查看
    • host中能夠使用localhost或127.0.0.1測試
  17. AttributeError: 'module' object has no attribute 'connect'
    • 模塊是否正確安裝,若是已經安裝
    • 檢查py文件名和模塊名重複
  18. pymysql.err.OperationalError: (1044, "Access denied for user 'guest'@'%' to database 'test'")
    • 一般是connect中的參數有誤
  19. pymysql.err.OperationalError: (1045, "Access denied for user 'guest'@'192.168.0.103' (using password: YES)")
    • 一般是鏈接參數有誤
相關文章
相關標籤/搜索