博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
mysql踩过的坑
阅读量:4327 次
发布时间:2019-06-06

本文共 2602 字,大约阅读时间需要 8 分钟。

  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)")
    • 通常是连接参数有误

转载于:https://www.cnblogs.com/henryw/p/10965946.html

你可能感兴趣的文章
Leetcode 6——ZigZag Conversion
查看>>
dockerfile_nginx+PHP+mongo数据库_完美搭建
查看>>
Http协议的学习
查看>>
【转】轻松记住大端小端的含义(附对大端和小端的解释)
查看>>
设计模式那点事读书笔记(3)----建造者模式
查看>>
ActiveMQ学习笔记(1)----初识ActiveMQ
查看>>
Java与算法之(2) - 快速排序
查看>>
Windows之IOCP
查看>>
机器学习降维之主成分分析
查看>>
CTP2交易所成交回报
查看>>
WebSocket & websockets
查看>>
openssl 升级
查看>>
ASP.NET MVC:通过 FileResult 向 浏览器 发送文件
查看>>
CVE-2010-2883Adobe Reader和Acrobat CoolType.dll栈缓冲区溢出漏洞分析
查看>>
使用正确的姿势跨域
查看>>
AccountManager教程
查看>>
Android学习笔记(十一)——从意图返回结果
查看>>
算法导论笔记(四)算法分析常用符号
查看>>
ultraedit激活
查看>>
总结(6)--- python基础知识点小结(细全)
查看>>