简体   繁体   English

回复:MySQL 8.0 命令行客户端错误 1205

[英]Re: MySQL 8.0 Command Line Client Error 1205

MySQL 8.0 Command Line Client is giving me a timeout error and I have restarting the transaction by typing "start transaction" another time. MySQL 8.0 命令行客户端给我一个超时错误,我已经通过再次键入“开始事务”来重新启动事务。 Keep in mind that I have another command line open with the table CIA_DATA.new_table and it is also being updated with the same changes.请记住,我打开了另一个带有表 CIA_DATA.new_table 的命令行,并且它也正在使用相同的更改进行更新。 (I am doing this to follow a tutorial.) Here is the script: (我这样做是为了遵循教程。)这是脚本:

mysql> start transaction;
Query OK, 0 rows affected (0.00 sec)

mysql> update CIA_DATA.new_table set c1 = 2 where c1 = 1;
ERROR 1205 (HY000): Lock wait timeout exceeded; try restarting transaction

Updated code for help in Answers Comments:更新了答案评论中的帮助代码:

mysql> set autocommit=0;
Query OK, 0 rows affected (0.00 sec)

mysql> start transaction;
Query OK, 0 rows affected (0.00 sec)

mysql> drop table CIA_DATA.new_table;
ERROR 1051 (42S02): Unknown table 'cia_data.new_table'
mysql> create table CIA_DATA.new_table ( c1 int primary key);
Query OK, 0 rows affected (0.08 sec)

mysql> insert into CIA_DATA.new_table values (1);
Query OK, 1 row affected (0.00 sec)

mysql> commit;
Query OK, 0 rows affected (0.05 sec)

mysql> select * from CIA_DATA.new_table;
+----+
| c1 |
+----+
|  1 |
+----+
1 row in set (0.00 sec)

mysql> update CIA_DATA.new_table set c1 = 2 where c1 = 1;
Query OK, 1 row affected (0.05 sec)
Rows matched: 1  Changed: 1  Warnings: 0

mysql> close transaction
    -> \c
mysql> close transaction;
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 'close transaction' at line 1
mysql> --innodb-lock-wait-timeout=#
    -> \c
mysql> --innodb-lock-wait-timeout=#;
    ->

Thanks, thecoolgeek谢谢,酷极客

What happen ony your computer:你的电脑会发生什么:

  1. One transaction locks the table and you didn't release the lock by endind the transaction.一个事务锁定了表,并且您没有通过结束事务释放锁定。

  2. you start a new tansaction and it encounters a lockesd table and waits for the release你开始一个新的事务,它遇到一个 lockesd 表并等待释放

  3. As the first transaction and the lock wasn't released, the secnd goes into to timeout.由于第一个事务和锁没有被释放,第二个事务进入超时。

Locks are in the best case difficult.锁在最好的情况下是困难的。 and sometimes it takes hours or days to solve them.有时需要数小时或数天才能解决它们。

so close the tranaction as fast as you can, so that the timeout not happen or increase the timeout https://dev.mysql.com/doc/refman/8.0/en/innodb-parameters.html#sysvar_innodb_lock_wait_timeout所以尽可能快地关闭交易,这样超时就不会发生或增加超时https://dev.mysql.com/doc/refman/8.0/en/innodb-parameters.html#sysvar_innodb_lock_wait_timeout

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM