Mysql 使用遇到的问题总结一

一、导入数据时:1062 - Duplicate entry ‘0’ for key ‘PRIMARY’

  • 原因:
    • 主键重复,或者设置了唯一索引
  • 二、Column count doesn’t match value count at row 1

    • 解释:
      • 存储的数据与数据库表的字段类型定义不相匹配。
    • 解决办法:
      • 检查段类型是否正确, 是否越界,有无把一种类型的数据存储到另一种数据类型中.看看dao层访问数据库的sql语句是否书写错误,赋值的参数是否与字段类型一致
    • 可能原因:
      • 列数不相等; 书写错误;
  • 三、Packet for query is too large

    • 问题列表:
    • 描述:
      • mysql的max_allowed_packet设置过小引起的,默认设置的是 1024. mysql 根据配置文件会限制 server接受的数据包大小,有时候大的插入和更新会被max_allowed_packet 参数限制。导致失败
    • 图片显示:
    • 执行命令:
      • set global max_allowed_packet = 210241024*10;
  • 四、Mysql 远程连接缓慢的问题

    • 在 [mysqld] 下添加
      • skip-name-resolve
    • 可能的原因:
      • mysql主机查询DNS很慢;
      • 有很多客户端主机时会导致连接很慢;
  • 五、[Err] 1093 - You can’t specify target table ‘x’ for update in FROM clause

    • 例子:
      • UPDATE user SET name=“onenote” WHERE id IN (SELECT id FROM user  WHERE id = 4967 AND STATUSIN (0, 1, 4));
    • 原因:
      • update语句中包含的子查询的表和update的表为同一张表时,报错:1093-Youcan’t specify target table for update in FROM clause
      • mysql不允许update目标表和子查询里面的表为同一张表
    • 解决办法:
      • 利用子查询sql可以改变双层的子查询,即可执行成功 (但性能较差,仅仅适合较小的数据量的)
    • 修改:
      • UPDATE user  SET name=“onenote” WHERE id IN(SELECT * FROM ( SELECT u.idFROM user u WHERE id = 4967 ANDSTATUS IN (0, 1, 4)) AS temp);
  • 六、Lock wait timeout exceeded; try restarting transaction。

    • 描述:
      • ERROR 1205(HY000): Lock wait timeout exceeded; try restarting transaction。
    • 解决方式:
      • 1、查看数据库事务隔离级别
        • select @@transaction_isolation;
      • 2、查看当前数据库的线程情况;
        • show full processlist
      • 3、如果没有查看到执行的较慢的sql记录线程,就查看innodb 的事务表INNODB_TRX, 查看是否有正在锁定的事务线程,看看其id 是否存在于 show fullprocesslist 的sleep线程中,如果是,就证明这个sleep 的线程事务一直没有commit或者rollback,线程阻塞了。手动kill 掉;
        • 1、select * from information_schema.INNODB_TRX;
        •    2、kill 114849
  • 七、错误: java.math.BigInteger在连接MySQL时无法强制转换为java.lang.Long (ClassCastException:)

    • 显示:
      • Caused by:java.lang.ClassCastException: java.math.BigInteger cannot be cast tojava.lang.Long
    • 可能原因:
      • 当我们要求JDBC驱动程序建立连接时,它在场景之后做了很多工作,然后才真正给我们提供了正确的连接工作对象。
      • 您的MySQL版本与您的mysql-connector.jar版本相结合似乎存在问题。尝试使用较新版本的MySQLConnector (请升级到8.0.12版。)

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
1. If the guaranteed yield were not reached, __________(我们将补偿损失). 2.If ______(美国没有参加第二次世界大战),probably the unemployment rate 14% would have risen still further. 3.If you hadn't watched that late movie last night, ______(你现在就不会困). 4.We wouldn't lose courage ______(即使我们再一次失败). 5.She returned, and ______(她会说更多的话)had he not walked away. 6. The business is risky, but it will be terrific if we give it a try. ______(如果我们成功的话), we would be rich. 7.If we hadn't got everything ready by now, ______(我们明天就会很麻烦了). 8.______(他本来会给我们更多的帮助), but he has been so busy. 9.But that ______(他当缺钱), he would have come to help us. 10.I was ill that day. Otherwise ______(我会参加聚会). 11.I would go to visit that beautiful lake but I______(联系不上你)while I am now in Boston. 12.I would have asked him to attend out gathering but ______(我不知道他的地址). 13.He knows that he shouldn't have done it, he wished ______(他没做这件事). 14.I wish ______(我呆在家里), I don't like this place. 15.John wants to see me today, but I would rather ______(他明天来). 16.His teacher recommended that he______(在大学一年级学一门外语)instead of waiting until the following year. 17.The housemaster was very strict, and he requested that we ______(不要在晚上看电视). 18.When Edison died, it was proposed that ______(美国人关掉所有电灯)for several minutes in honor of this great man. 19.It is most important that ______(车闸工作正常). 20.One of the requirements for a fire is that the material ______(加热到燃烧的温度). 21.What do you think of his motion that we ______(将会议推迟)? 22.I think it is high time that Mr. Smith ______(下定决心). 23.Violetta has a curious expression on her face as though she ______(正在为某事发笑). 24.Every attention must be paid to him, lest ______(他觉得不如其他客人). 25.If only ______(工作再细心一点). 26.May this book in a small way ______(有助于促进两国之间的理解和友谊). 27.In this country it is required that anyone who has recently come here ______(必须交税). 28.______(不管天气好坏),we will set off as we planned. 1. we would make up the loss. 2. the United States had not entered the Second World War 3. you wouldn't be sleepy now 4. even if we were to fail again 5. would have said more 6. Should we succeed 7. we would have a terrible time tomorrow 8. He would have given more help 9. he was short of money at

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值