广告
返回顶部
首页 > 资讯 > 数据库 >MySQL 8.0限制用户并发连接数的两个参数
  • 689
分享到

MySQL 8.0限制用户并发连接数的两个参数

mysql数据库java 2023-08-17 08:08:56 689人浏览 泡泡鱼
摘要

Mysql 8.0限制用户并发连接数的两个参数 max_connectionsmax_user_connections max_connections 针对所有用户总体而言,MySQL Server允许的最大并发客户端连接数,默

Mysql 8.0限制用户并发连接数的两个参数

max_connections

针对所有用户总体而言,MySQL Server允许的最大并发客户端连接数,默认值为151,可以根据服务器配置适当调大到1000。

最大并发连接数max_connections的实际生效值等于它的配置值与open_files_limit配置值两者中的较小值。open_files_limit参数定义了mysqld进程能够使用的操作系统文件描述符的数量。

最大并发连接数max_connections为全局系统变量。

修改最大并发连接数max_connections

set global max_connections = 1000;set @@global.max_connections = 1000;

修改最大并发连接数max_connections的运行时值,并将其持久化到mysqld-auto.cnf文件:

set persist max_connections = 1000;set @@persist.max_connections = 1000;

max_user_connections

针对单个MySQL用户而言,所允许的最大并发连接数。默认值为0,表示没有限制。

用户最大并发连接数max_user_connections既有全局级别的参数值,也有会话级别的参数值。全局级别的max_user_connections可以动态修改。会话级别的max_user_connections为只读变量,其生效值通过以下方式来确定:

  1. 如果为用户设置的最大并发连接数max_user_connections的值不为0,那么该值即为会话级别max_user_connections的生效值;

  2. 如果为用户设置的最大并发连接数max_user_connections的值为0,那么会话级别max_user_connections的生效值即为全局级别的配置值。

修改用户的最大并发连接数max_user_connections

alter user xxx with max_user_connections 0;

修改全局级别的用户最大并发连接数max_user_connections

set global max_user_connections = 0;

🌻常用查询命令:

--查看用户的并发连接数限制select user,host,max_connections,max_user_connections from mysql.user;--查看全局级别的用户最大并发连接数show global variables like 'max_user_connections';--查看会话级别的用户最大并发连接数show session variables like 'max_user_connections';

References
[1] https://dev.mysql.com/doc/refman/8.0/en/user-resources.html
[2] Https://dev.mysql.com/doc/refman/8.0/en/server-system-variables.html#sysvar_max_user_connections
[3] https://dev.mysql.com/doc/refman/8.0/en/server-system-variables.html#sysvar_max_connections
[4] https://dev.mysql.com/doc/refman/8.0/en/server-system-variables.html#sysvar_open_files_limit

来源地址:https://blog.csdn.net/Sebastien23/article/details/130094075

您可能感兴趣的文档:

--结束END--

本文标题: MySQL 8.0限制用户并发连接数的两个参数

本文链接: https://www.lsjlt.com/news/372531.html(转载时请注明来源链接)

有问题或投稿请发送至: 邮箱/279061341@qq.com    QQ/279061341

本篇文章演示代码以及资料文档资料下载

下载Word文档到电脑,方便收藏和打印~

下载Word文档
猜你喜欢
软考高级职称资格查询
编程网,编程工程师的家园,是目前国内优秀的开源技术社区之一,形成了由开源软件库、代码分享、资讯、协作翻译、讨论区和博客等几大频道内容,为IT开发者提供了一个发现、使用、并交流开源技术的平台。
  • 官方手机版

  • 微信公众号

  • 商务合作