Linux下mysql修改连接超时wait_timeout

1,首先:

show variables like '%timeout%';

显示结果:

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

| Variable_name               | Value    |

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

| connect_timeout             | 10       |

| delayed_insert_timeout      | 300      |

| innodb_flush_log_at_timeout | 1        |

| innodb_lock_wait_timeout    | 50       |

| 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           | 3600     |

| wait_timeout                | 28800    |

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

12 rows in set (0.00 sec)

其中有用的是: interactive_timeout  和wait_timeout  为28800,默认为8小时设置;

一般线上的环境中mysql中连接时间设置为7天即可;

2,其次:

执行命令:       set  interactive_timeout=604800;

set  wait_timeout=604800;

最后:执行​show variables like '%timeout%';看看执行成功没有,显示结果为:

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

| Variable_name               | Value    |

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

| connect_timeout             | 10       |

| delayed_insert_timeout      | 300      |

| innodb_flush_log_at_timeout | 1        |

| innodb_lock_wait_timeout    | 50       |

| innodb_rollback_on_timeout  | OFF      |

| interactive_timeout         | 604800   |

| lock_wait_timeout           | 31536000 |

| net_read_timeout            | 30       |

| net_write_timeout           | 60       |

| rpl_stop_slave_timeout      | 31536000 |

| slave_net_timeout           | 3600     |

| wait_timeout                | 604800   |

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

12 rows in set (0.00 sec)

表明执行成功了。。。

Could not open Hibernate Session for transaction; nested exception is org.hibernate.TransactionExcep linux下mysql修改连接超时wait_timeout修改后就ok了的更多相关文章

  1. org.springframework.transaction.CannotCreateTransactionException: Could not open Hibernate Session for transaction; nested exception is org.hibernate.exception.JDBCConnectionException: Cannot open con

    org.springframework.transaction.CannotCreateTransactionException: Could not open Hibernate Session f ...

  2. 解决Could not open Hibernate Session for transaction; nested exception is java.lang.NoClassDefFoundError: org/hibernate/engine/transaction/spi/TransactionContext

    我使用的是5.2.8的hibernate的jar包,运行的时候却报错Could not open Hibernate Session for transaction; nested exception ...

  3. 解决Exception:Could not open Hibernate Session for transaction; nested exception is java.lang.NoClassDefFoundError: org/hibernate/engine/transaction/spi/TransactionContext

    原因是配置文件中 <bean id="transactionManager" class="org.springframework.orm.hibernate4.H ...

  4. 异常:getHibernateFlushMode is not valid without active transaction; nested exception is org.hibernate.HibernateException: getHibernateFlushMode is not valid without active transaction getHibernateFlu

    场景: 在使用spring整合hibernate调用的HibernateTemplate时报错解决: 在spring配置文件中添加事务的配置 <bean id="hibernateTr ...

  5. Exceprtion:e createQuery is not valid without active transaction; nested exception is org.hibernate.HibernateException: createQuery is not valid without active transaction

    如果增加配置了current_session_context_class属性,查询的时候需要session.beginTrasaction()来开启事务

  6. Could not open Hibernate Session for transaction;

    javax.servlet.ServletException: org.springframework.transaction.CannotCreateTransactionException: Co ...

  7. SSH项目过一段时间之后再访问会报一次Could not open Hibernate session for transaction 异常,Caused by: com.mysql.jdbc.CommunicationsException: Communications link failure due to underlyi,再重新方法即可访问成功(通常出现在过了一晚之后再去访问系统)

    前端时间到客户那去进行项目的上线测试,将项目部署好之后,运行都是正常的,可是每到了第二天早上访问的时候,就会报一个Could not open Hibernate session for transa ...

  8. Could not open JPA EntityManager for transaction; nested exception is javax.persistence.PersistenceException: org.hibernate.exception.SQLGrammarException: Cannot open connection

    Could not open JPA EntityManager for transaction; nested exception is javax.persistence.PersistenceE ...

  9. Hibernage错误:Could not open Hibernate Session for transaction

    今天客户发来的错误,是SSH框架做的项目,是用户在登陆时候出现的错误,但刷新之后就没问题. 提示错误:Could not open Hibernate Session for transaction. ...

随机推荐

  1. cf1208 D Restore Permutation (二分+树状数组)

    题意 让你构造一个长度为n的序列,记为p1……pn,(这个序列是1~n的全排列的一种) 给你n个数,记为s1……sn,si的值为p1……pi-1中小于pi的数的和. 思路 显然,应该倒着来,也就是从p ...

  2. openstack trove redis配置项

    trove在mitaka版本更新了一个功能,configuration 具体如下: trove help |grep configuration configuration-attach Attach ...

  3. Arduino IIC 主从设备连接通信

    目的:        实现Arduino主从设备之间的互相IIC通信,掌握IIC通信协议的使用方法. 器材: Arduino UNO R3 一块 Arduino Nano 三块 面包板   导线 3K ...

  4. 第一个eclipse maven项目!我超全!

    前言:以前一直用idea做东西,今天突然想试一下,没想到配置起来是真的麻烦!!!!会出现各种各样的问题,太晚了,本文只做出几处非常严重的问题,如有疑问,请私信,留言 准备:本文     JDK 1.8 ...

  5. Vue-router(1)之component标签

    1. 使用 <component>标签实现组件切换 <component> 是Vue提供的标签语法:有一个is属性,is的作用就是显示指定的组件 <template> ...

  6. VUE- 解决插件报错问题

    VUE- 解决插件报错问题 解决办法:先删除node_modules整个文件夹,然后cnpm cache clean,然后cnpm install. cnpm  cache clean时可能会提示 这 ...

  7. retrofit 上传文件 跟参数

    @Multipart @POST("postFied") Call<Void> postFied(@PartMap Map<String,String> m ...

  8. css实现高度自适应

    要求.上部固定高度50px,下部分自适应剩下整个屏幕 html, body { height: 100%; margin: 0px; padding: 0px; } #main { backgroun ...

  9. 基于JSP+Servlet新闻发布系统 源码

    开发环境: Windows操作系统开发工具: Eclipse+Jdk+Tomcat+MYSQL数据库 运行效果图:

  10. 201312-1 出现次数最多的数Java

    import java.util.HashMap; import java.util.Iterator; import java.util.Map; import java.util.Scanner; ...