zoukankan      html  css  js  c++  java
  • MySQL命令行

    • 查看进程列表:show processlist; Sleep表示当前有一个空闲连接

      mysql> show processlist;
      +----+------+-----------------+----------+---------+------+----------+------------------+
      | Id | User | Host            | db       | Command | Time | State    | Info             |
      +----+------+-----------------+----------+---------+------+----------+------------------+
      | 34 | root | localhost:62974 | NULL     | Query   |    0 | starting | show processlist |
      | 35 | root | localhost:62979 | cmsdbdev | Sleep   |    2 |          | NULL             |
      +----+------+-----------------+----------+---------+------+----------+------------------+
      2 rows in set (0.00 sec)
      
    • 查看参数:show variables like 'wait%'; 等待超时时间默认是8小时,超过此值客户端就会被断开

      mysql> show variables like 'wait%';
      +---------------+-------+
      | Variable_name | Value |
      +---------------+-------+
      | wait_timeout  | 28800 |
      +---------------+-------+
      1 row in set, 1 warning (0.00 sec)
      
    • 修改参数:set wait_timeout = 60; 修改变量的值

      • 默认修改的参数只对当前会话起作用,相当于 set SESSION
      • 如果需要修改全局,使用 set GLOBAL
      mysql> set wait_timeout = 60;
      Query OK, 0 rows affected (0.00 sec)
      
      mysql> show variables like 'wait%';
      +---------------+-------+
      | Variable_name | Value |
      +---------------+-------+
      | wait_timeout  | 60    |
      +---------------+-------+
      1 row in set, 1 warning (0.00 sec)
      
      ## 全局修改,对当前会话不起作用,对新创建的会话起作用
      mysql> set GLOBAL wait_timeout = 60;
      Query OK, 0 rows affected (0.00 sec)
      
      mysql> show variables like 'wait%';
      +---------------+-------+
      | Variable_name | Value |
      +---------------+-------+
      | wait_timeout  | 28800 |
      +---------------+-------+
      1 row in set, 1 warning (0.00 sec)
      
      ## 重新打开一个会话
      

      超过一分钟后,再次查询,报错了:

      mysql> show variables like 'wait%';
      ERROR 2013 (HY000): Lost connection to MySQL server during query
      
  • 相关阅读:
    SpringMVC金课-课程大纲
    Type Cannot change version of project facet Dynamic Web Module to 3.0.
    使用maven 创建web项目 + 搭建SSM框架
    多文件上传
    asp.net 连接access数据库方法
    分享代码
    DIV+CSS解决IE6,IE7,IE8,FF兼容问题(转至http://www.douban.com/note/163291324/)
    asp.net发布网站(转)
    Img垂直居中
    http://www.apkbus.com/android-6231-1.html
  • 原文地址:https://www.cnblogs.com/HeCG95/p/12166512.html
Copyright © 2011-2022 走看看