mysql 常见报错

1.mysql 1205  Lock wait timeout exceeded; try restarting transaction

记一次特别奇怪的mysql报错

2.Column 'id' in where clause is ambiguous

这个错误是因为多表查询的时候几个表中同时出现了某个相同的列名,而在查询条件WHERE后面又没有指定是那个表,而引起的

又或者是查询结果里面有两个相同的列名,而没有指定是哪个表使用的时候可以这样.

 

1.怀疑是否有正在执行的事务没有提交,进行查询。

select * from information_schema.PROCESSLIST a , information_schema.INNODB_TRX b where b.trx_mysql_thread_id=a.id order by 1 desc

查看数据库的进程表

show full processlist;

查看事物表

select* from information_schema.innodb_trx;

如果有未提交的事务可以通过 kill + id解决;

按照网上的处理方案,查询并没有未提交的事务。

 

2.查询是可以的,只要用到了临时表,查询就卡住了,想了各种方法还是不行,最后把数据库备份出来,还原到不同实例下就可以了,没有找到是什么原因导致的。

折腾了好久。 遇到特别棘手的问题,不妨换个思路。。。。mysql真是博大精深,搞不懂。

 

2.[Err] 1418 - This function has none of DETERMINISTIC, NO SQL, or READS SQL DATA in its declaration and binary logging is enabled (you *might* want to use the less safe log_bin_trust_function_creators variable)

解决方法:

root用户下在客户端上执行SET GLOBAL log_bin_trust_function_creators = 1;

posted @ 2021-03-12 13:26  宋军涛  阅读(107)  评论(0编辑  收藏  举报