zoukankan      html  css  js  c++  java
  • max_connections Max_used_connections

    MySQL的max_connections参数用来设置最大连接(用户)数。每个连接MySQL的用户均算作一个连接,max_connections的默认值为100。本文将讲解此参数的详细作用与性能影响。

    与max_connections有关的特性

    MySQL无论如何都会保留一个用于管理员(SUPER)登陆的连接,用于管理员连接数据库进行维护操作,即使当前连接数已经达到了max_connections。因此MySQL的实际最大可连接数为Max_used_connections=max_connections+1;
    这个参数实际起作用的最大值(实际最大可连接数)为16384,即该参数最大值不能超过16384,即使超过也以16384为准;
    增加max_connections参数的值,不会占用太多系统资源。系统资源(CPU、内存)的占用主要取决于查询的密度、效率等;
    该参数设置过小的最明显特征是出现”Too many connections”错误;

    我们先来看下如何查看当前mysql的max_connections的值:

    show variables like "max_connections";

    显示的结果如下格式

    +-----------------+-------+
    | Variable_name   | Value |
    +-----------------+-------+
    | max_connections | 100   |
    +-----------------+-------+

    可以通过下面的sql语句将max_connections的值设置为200,当然前提是当前登录的用户有足够的权限:

    set global max_connections = 200;

    这个设置会马上生效,但是当mysql重启时这个设置会失效,更好的办法是修改mysql的配置文件my.cnf

    找到mysqld块,修改或者添加下面的设置:

    max_connections=200

    这样修改之后,即便重启mysql也会默认载入这个配置了

     不过为了安全期间,建议大家直接到my.cnf里修改。

  • 相关阅读:
    PHP全路径无限分类原理
    SecureCRT上传bash: rz: command not found
    Android利用Fiddler进行网络数据抓包【怎么跟踪微信请求】
    Creating the Help Page in ASP.NET Web API
    Windows上怎么安装ELK
    安装ELK
    How to kill a process on a port on linux 怎么杀死 关掉一个端口
    How to install Mysql in the CentOS
    Hadoop: Setup Maven project for MapReduce in 5mn
    Install Ambari 2.2.0 from Public Repositories(Hadoop)
  • 原文地址:https://www.cnblogs.com/vzhangxk/p/15423091.html
Copyright © 2011-2022 走看看