<i id='llyzO'><tr id='llyzO'><dt id='llyzO'><q id='llyzO'><span id='llyzO'><b id='llyzO'><form id='llyzO'><ins id='llyzO'></ins><ul id='llyzO'></ul><sub id='llyzO'></sub></form><legend id='llyzO'></legend><bdo id='llyzO'><pre id='llyzO'><center id='llyzO'></center></pre></bdo></b><th id='llyzO'></th></span></q></dt></tr></i><div id='llyzO'><tfoot id='llyzO'></tfoot><dl id='llyzO'><fieldset id='llyzO'></fieldset></dl></div>
      1. <small id='llyzO'></small><noframes id='llyzO'>

        <legend id='llyzO'><style id='llyzO'><dir id='llyzO'><q id='llyzO'></q></dir></style></legend>
        • <bdo id='llyzO'></bdo><ul id='llyzO'></ul>

        <tfoot id='llyzO'></tfoot>

        终止空闲的 mysql 连接

        时间:2023-05-24
              <tbody id='wcQvt'></tbody>

          • <legend id='wcQvt'><style id='wcQvt'><dir id='wcQvt'><q id='wcQvt'></q></dir></style></legend>

                <bdo id='wcQvt'></bdo><ul id='wcQvt'></ul>
                <tfoot id='wcQvt'></tfoot>

                • <i id='wcQvt'><tr id='wcQvt'><dt id='wcQvt'><q id='wcQvt'><span id='wcQvt'><b id='wcQvt'><form id='wcQvt'><ins id='wcQvt'></ins><ul id='wcQvt'></ul><sub id='wcQvt'></sub></form><legend id='wcQvt'></legend><bdo id='wcQvt'><pre id='wcQvt'><center id='wcQvt'></center></pre></bdo></b><th id='wcQvt'></th></span></q></dt></tr></i><div id='wcQvt'><tfoot id='wcQvt'></tfoot><dl id='wcQvt'><fieldset id='wcQvt'></fieldset></dl></div>

                  <small id='wcQvt'></small><noframes id='wcQvt'>

                  本文介绍了终止空闲的 mysql 连接的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  限时送ChatGPT账号..

                  我看到很多连接都打开并保持空闲很长时间,比如 5 分钟.

                  I see a lot of connections are open and remain idle for a long time, say 5 minutes.

                  是否有任何解决方案可以在不重新启动 mysql 服务的情况下从服务器终止/关闭它?

                  Is there any solution to terminate / close it from server without restarting the mysql service?

                  我正在维护一个旧的 PHP 系统,无法关闭为执行查询而建立的连接.

                  I am maintaining a legacy PHP system and can not close the connections those are established to execute the query.

                  我应该将 my.cnf 文件中的超时值减少到 8 小时吗?

                  Should I reduce the timeout values in my.cnf file those defaults to 8 hours?

                  # default 28800 seconds
                  
                  interactive_timeout=60
                  wait_timeout=60
                  

                  推荐答案

                  手动清理:

                  您可以杀死进程 ID.

                  Manual cleanup:

                  You can KILL the processid.

                  mysql> show full processlist;
                  +---------+------------+-------------------+------+---------+-------+-------+-----------------------+
                  | Id      | User       | Host              | db   | Command | Time  | State | Info                  |
                  +---------+------------+-------------------+------+---------+-------+-------+-----------------------+
                  | 1193777 | TestUser12 | 192.168.1.11:3775 | www  | Sleep   | 25946 |       | NULL                  |
                  +---------+------------+-------------------+------+---------+-------+-------+-----------------------+
                  
                  mysql> kill 1193777;
                  

                  但是:

                  • php 应用程序可能会报告错误(或网络服务器,检查错误日志)
                  • 不要修复没有损坏的东西 - 如果您的连接不短缺,只需离开他们吧.
                  • the php application might report errors (or the webserver, check the error logs)
                  • don't fix what is not broken - if you're not short on connections, just leave them be.

                  或者您通过在 wait_timeoutinteractive_timeout

                  Or you configure your mysql-server by setting a shorter timeout on wait_timeout and interactive_timeout

                  mysql> show variables like "%timeout%";
                  +--------------------------+-------+
                  | Variable_name            | Value |
                  +--------------------------+-------+
                  | connect_timeout          | 5     |
                  | delayed_insert_timeout   | 300   |
                  | innodb_lock_wait_timeout | 50    |
                  | interactive_timeout      | 28800 |
                  | net_read_timeout         | 30    |
                  | net_write_timeout        | 60    |
                  | slave_net_timeout        | 3600  |
                  | table_lock_wait_timeout  | 50    |
                  | wait_timeout             | 28800 |
                  +--------------------------+-------+
                  9 rows in set (0.00 sec)
                  

                  设置:

                  set global wait_timeout=3;
                  set global interactive_timeout=3;
                  

                  (也在你的配置文件中设置,当你的服务器重启时)

                  (and also set in your configuration file, for when your server restarts)

                  但是您正在治疗症状而不是根本原因 - 为什么这些联系是开放的?如果 PHP 脚本完成,它们不应该关闭吗?确保您的网络服务器没有使用连接池...

                  But you're treating the symptoms instead of the underlying cause - why are the connections open? If the PHP script finished, shouldn't they close? Make sure your webserver is not using connection pooling...

                  这篇关于终止空闲的 mysql 连接的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                  上一篇:带有 MySQL 数据库的 Python 3.4.0 下一篇:无法连接到“本地主机"上的 MySQL 服务器 (10061)

                  相关文章

                    <bdo id='Lk0a6'></bdo><ul id='Lk0a6'></ul>
                    <legend id='Lk0a6'><style id='Lk0a6'><dir id='Lk0a6'><q id='Lk0a6'></q></dir></style></legend>

                    <small id='Lk0a6'></small><noframes id='Lk0a6'>

                  1. <i id='Lk0a6'><tr id='Lk0a6'><dt id='Lk0a6'><q id='Lk0a6'><span id='Lk0a6'><b id='Lk0a6'><form id='Lk0a6'><ins id='Lk0a6'></ins><ul id='Lk0a6'></ul><sub id='Lk0a6'></sub></form><legend id='Lk0a6'></legend><bdo id='Lk0a6'><pre id='Lk0a6'><center id='Lk0a6'></center></pre></bdo></b><th id='Lk0a6'></th></span></q></dt></tr></i><div id='Lk0a6'><tfoot id='Lk0a6'></tfoot><dl id='Lk0a6'><fieldset id='Lk0a6'></fieldset></dl></div>

                  2. <tfoot id='Lk0a6'></tfoot>