mysql connect 超时_MySQL修改connect_timeout(连接超时)全局变量

Java程序员儿反应服务器上的MySQL连上去之后,总是过一会儿就断开连接了,工作效率低,跟松哥提需求,增加连接时间,减少断开次数,和刷新页面的等待时间。我自己本地用telnet测试,读秒试了下,果然是过了几秒就断开了。

telnet 测试数据库的连接超时时间

telnet 121.43.161.35 3306

1.登录mysql数据库

[root@iZbp11rfoyeescusr9ha9qZ conf]# mysql -u root -p

2.查询匹配“timeout”的全局变量

MySQL [(none)]> show global variables like '%timeout%';

+----------------------------------------+--------------+

| Variable_name | Value |

+----------------------------------------+--------------+

| connect_timeout | 10 |

| delayed_insert_timeout | 300 |

| have_statement_timeout | YES |

| innodb_flush_log_at_timeout | 1 |

| innodb_lock_wait_timeout | 120 |

| innodb_rollback_on_timeout | OFF |

| interactive_timeout | 28800 |

| lock_wait_timeout | 31536000 |

| net_read_timeout | 30 |

| net_write_timeout | 60 |

| rpl_stop_slave_timeout | 31536000 |

| slave_net_timeout | 60 |

| wait_timeout | 28800 |

+-----------------------------------------+--------------+

13 rows in set (0.01 sec)

3.设置全局变量connect_timeout为12小时(12*3600=43200)

MySQL [(none)]> SET GLOBAL connect_timeout = 43200;

Query OK, 0 rows affected (0.00 sec)

4.再次查看,确认参数是否修改成功

MySQL [(none)]> show global variables like '%timeout%';

+----------------------------------------+--------------+

| Variable_name | Value |

+----------------------------------------+--------------+

| connect_timeout | 43200 |

| delayed_insert_timeout | 300 |

| have_statement_timeout | YES |

| innodb_flush_log_at_timeout | 1 |

| innodb_lock_wait_timeout | 120 |

| innodb_rollback_on_timeout | OFF |

| interactive_timeout | 28800 |

| lock_wait_timeout | 31536000 |

| net_read_timeout | 30 |

| net_write_timeout | 60 |

| rpl_stop_slave_timeout | 31536000 |

| slave_net_timeout | 60 |

| wait_timeout | 28800 |

+-----------------------------------------+--------------+

13 rows in set (0.00 sec)

5.退出数据库

MySQL [(none)]> exit

Bye

  • 0
    点赞
  • 6
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值