`

linux设置mysql innodb_lock_wait_timeout的值

阅读更多

root权限下:

vi /etc/my.cnf

在[mysqld]配置下面加入

innodb_lock_wait_timeout=value # value是你想设置的值

重启mysql

/etc/init.d/mysqld restart

 

 

reference:

http://dev.mysql.com/doc/refman/5.0/en/option-files.html

http://dev.mysql.com/doc/refman/5.0/en/innodb-parameters.html#sysvar_innodb_lock_wait_timeout

http://dev.mysql.com/doc/refman/5.0/en/command-line-options.html

以上是mysql官方文档,以下是摘录:

innodb_lock_wait_timeout

Command-Line Format --innodb_lock_wait_timeout=#
Option-File Format innodb_lock_wait_timeout
Option Sets Variable Yes, innodb_lock_wait_timeout
Variable Name innodb_lock_wait_timeout
Variable Scope Global
Dynamic Variable No
Permitted Values
Type numeric
Default 50
Range 1 .. 1073741824

The timeout in seconds an InnoDB transaction may wait for a row lock before giving up. The default value is 50 seconds. A transaction that tries to access a row that is locked by another InnoDB transaction will hang for at most this many seconds before issuing the following error:

ERROR 1205 (HY000): Lock wait timeout exceeded; try restarting transaction

When a lock wait timeout occurs, the current statement is not executed. The current transaction is not rolled back. (Until MySQL 5.0.13 InnoDB rolled back the entire transaction if a lock wait timeout happened. You can restore this behavior by starting the server with the --innodb_rollback_on_timeout option, available as of MySQL 5.0.32. See also Section 13.2.12, “InnoDB Error Handling” .)

innodb_lock_wait_timeout applies to InnoDB row locks only. A MySQL table lock does not happen inside InnoDB and this timeout does not apply to waits for table locks.

InnoDB does detect transaction deadlocks in its own lock table immediately and rolls back one transaction. The lock wait timeout value does not apply to such a wait.

 

innodb_lock_wait_timeout不能动态的runtime修改,但是可以在启动时添加启动参数和在配置文件中修改。

但是试了好几次,按文档

mysql -u user --innodb_lock_wait_timeout=#value

or

mysql -u user --innodb_lock_wait_timeout=value

...

不成功,不知道是不是没读明白文档。

分享到:
评论

相关推荐

    MYSQL innodb性能优化学习总结

    - **innodb_lock_wait_timeout**:控制等待锁释放的超时时间,默认为50秒,如果业务操作耗时较长,可能需要适当调整该值以避免超时错误。 - **innodb_spin_wait_delay**:控制CPU轮询等待的时间间隔,过低可能导致...

    解决SQLSTATE[HY000]: General error: 1205 Lock wait timeout exceeded_runtimeerror怎么修复

    2. **调整锁等待超时时间**:通过设置`innodb_lock_wait_timeout`参数来增加等待超时时间。但请注意,这仅是权宜之计,不是根本解决方案。 3. **监控和分析**:使用`SHOW ENGINE INNODB STATUS;`命令查看当前的锁...

    可以改善mysql性能的InnoDB配置参数

    13. **innodb_lock_wait_timeout**:这个参数定义了当等待锁超时时的等待时间(以秒计)。如果设置得过短,可能导致事务频繁被中断;过长则可能导致死锁发生。 以上参数的优化需要根据实际应用的负载、硬件资源以及...

    my.cnf参数配置实现InnoDB引擎性能优化

    MySQL的InnoDB引擎是处理大数据量和高并发场景下的首选存储引擎,因为它具有事务处理、行级锁定以及数据一致性保障等特性。为了充分利用InnoDB的优势并优化其性能,正确配置MySQL的配置文件my.cnf至关重要。本文将...

    KFC系列之 - Oracle DBA入门Mysql(中)

    - **innodb_lock_wait_timeout**:设置在等待锁时的超时时间,单位为秒。如果超过了这个时间还没有获取到锁,那么会抛出错误并提示用户重启事务。 ##### 3. 锁相关字典表查询和命令 MySQL提供了几个系统视图来查看...

    MYSQL-innodb性能优化学习总结.pdf

    11. **innodb_lock_wait_timeout**:设定锁等待超时时间,避免死锁和长时间阻塞。应根据业务需求设定,避免过早中断长时间运行的任务。 在进行SQL性能分析时,`EXPLAIN`语句是关键工具。通过查看`EXPLAIN`的结果,...

    mysql支持事务配置,配置InnoDB引擎

    - **第16行**: `innodb_lock_wait_timeout=50` - 设置事务等待锁的超时时间。如果在此时间内未获得锁,则事务回滚。默认值为50秒。 - **第17行**: `innodb_log_files_in_group=3` - 设置日志组中日志文件的数量...

    MYSQL-innodb性能优化学习总结[收集].pdf

    11. **innodb_lock_wait_timeout**:设置锁定请求等待的最长时间,超过这个时间,MySQL将返回错误。需根据业务需求调整,避免因长时间等待导致的问题。 12. **Explain SQL分析**:通过`EXPLAIN`关键字可以分析SQL...

    mysql性能调优参数

    2. Innodb_lock_wait_timeout:这个参数确定 Innodb 事务在被回滚之前可以等待一个锁定的超时秒数,默认是 50 秒。 3. Innodb_max_dirty_pages_pct:这个参数确定 Innodb 主线程刷新缓存池中的数据,使脏数据比例...

    mysql-linux版详细安装教程

    innodb_lock_wait_timeout=30000 innodb_buffer_pool_size=48,234,496 innodb_log_file_size = 2G innodb_log_files_in_group = 5 innodb_undo_tablespaces=4 innodb_flush_log_at_trx_commit=2 key_buffer_size=...

    mysql配置文件常用修改.pdf

    innodb_lock_wait_timeout = 50 ``` 这些设置用于控制InnoDB引擎的各个方面,例如数据文件的位置、缓存池大小以及日志文件的大小。你可以通过`show engines;`和`show create table t1;`查看默认存储引擎和其他表的...

    MySQL参数说明

    * innodb_lock_wait_timeout:等待数据锁的超时时间,避免死锁的一种措施 * innodb_flush_log_at_trx_commit:日志提交方式(关键参数) + 0 每秒写 1 次日志,将数据刷入磁盘,相当于每秒提交一次事务 + 1 每次...

    mysql 5.5 配置文档

    25. `innodb_lock_wait_timeout`: 事务等待锁的超时时间。 26. `slow-query-log-file`: 慢查询日志文件,记录执行时间超过指定阈值的查询。 27. `long_query_time`: 设置慢查询的时间阈值,超过此时间的查询将被...

    linux MySQL 8.0二进制包安装

    innodb_lock_wait_timeout = 1500 max_connections=500 初始化数据库,并查看日志: bin/mysqld --initialize --user=mysql --basedir=/home/mysql --datadir=/home/mysql/data --lower-case-table-names=1 tailf ...

    mysql 性能的检查和优化方法

    13. **innodb_lock_wait_timeout** - **功能**:设置InnoDB锁等待超时时间。 - **建议值**:根据实际应用场景调整,通常推荐较高的值以避免频繁的死锁检测。 - **注意事项**:过低的值可能会导致更多死锁发生。 ...

Global site tag (gtag.js) - Google Analytics