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)")
    • 通常是连接参数有误
posted @ 2019-06-03 09:55  RunningForever  阅读(630)  评论(0编辑  收藏  举报