MYSQL max_user_connections back_log max_connections参数和Max_used_connections
短信预约 -IT技能 免费直播动态提醒
原创请注明出处
1、max_user_connections
max_user_connections这个参数是单个用户允许连接的最大会话数量,在建立用户的时候也有类似的限制,这里仅仅说的是这个参数
下面是官方文档说明:
The maximum number of simultaneous connections permitted to any given MySQL user account. A
value of 0 (the default) means “no limit.”
This variable has a global value that can be set at server startup or runtime. It also has a read-only
session value that indicates the effective simultaneous-connection limit that applies to the account
associated with the current session. The session value is initialized as follows:
? If the user account has a nonzero MAX_USER_CONNECTIONS resource limit, the session
max_user_connections value is set to that limit.
? Otherwise, the session max_user_connections value is set to the global value.
报错如下:
mysql: [Warning] Using a password on the command line interface can be insecure.
ERROR 1203 (42000): User root already has more than 'max_user_connections' active connections
2、max_connections
max_connections:这个参数是MYSQL服务端允许的最大连接会话数量,没什么好说的
下面是官方文档说明:
The maximum permitted number of simultaneous client connections. By default, this is 151. See
Section B.5.2.7, “Too many connections”, for more information.
Increasing this value increases the number of file descriptors that mysqld requires. If the required
number of descriptors are not available, the server reduces the value of max_connections. See
Section 9.4.3.1, “How MySQL Opens and Closes Tables”, for comments on file descriptor limits.
测试也非常简单报错如下:
[root@testmy ~]# /mysqldata/mysql5.7/bin/mysql --socket=/mysqldata/mysql5.7/mysqld3307.sock -utestmy -pGelc123123
mysql: [Warning] Using a password on the command line interface can be insecure.
ERROR 1040 (HY000): Too many connections
3、Max_used_connections 、Max_used_connections_time
这里还大概说一下
mysql> show global status like '%max%';
+-----------------------------------+---------------------+
| Variable_name | Value |
+-----------------------------------+---------------------+
| Max_used_connections | 7 |
| Max_used_connections_time | 2017-05-10 17:10:56 |
这两个状态说的是MYSQL SERVER自上次启动起来最大连接数量和发生的时间,和上面讲参数没任何关系。
? Max_used_connections
The maximum number of connections that have been in use simultaneously since the server started.
? Max_used_connections_time
The time at which Max_used_connections reached its current value. This variable was added in
MySQL 5.7.5
4、back_log
back_log:这个参数的解释相对于比较复杂和难以理解,难以理解是因为大多DBA对LINUX下C编程不熟悉,
这个参数说的就是sokcet编程中的listen调用的时候使用形参back_log
函数原型
int listen(int sockfd, int backlog);
man page中描述:
DESCRIPTION
listen() marks the socket referred to by sockfd as a passive socket, that is, as a socket that will be used to accept incoming connection requests using accept(2).
The sockfd argument is a file descriptor that refers to a socket of type SOCK_STREAM or SOCK_SEQPACKET.
The backlog argument defines the maximum length to which the queue of pending connections for sockfd may grow. If a connection request arrives when the queue is full, the client may receive an error with
an indication of ECONNREFUSED or, if the underlying protocol supports retransmission, the request may be ignored so that a later reattempt at connection succeeds.
RETURN VALUE
On success, zero is returned. On error, -1 is returned, and errno is set appropriately.
sockfd没什么好说的create的时候返回的scoket文件描述符,这里的backlog实际上是一个未决连接的一个队列,如果超过可能值会返回ECONNREFUSED的一个错误,但是如果底层协议支持retransmission,
,这个错误将被忽略然后再次尝试知道成功。它取决于LINUX系统设置/proc/sys/net/core/somaxconn和函数backlog的小值当然LINUX系统默认这个值是128.
下面是MYSQL官方文档描述:
The number of outstanding connection requests MySQL can have. This comes into play when the
main MySQL thread gets very many connection requests in a very short time. It then takes some
time (although very little) for the main thread to check the connection and start a new thread. The
back_log value indicates how many requests can be stacked during this short time before MySQL
momentarily stops answering new requests. You need to increase this only if you expect a large number
of connections in a short period of time.
In other words, this value is the size of the listen queue for incoming TCP/IP connections. Your operating
system has its own limit on the size of this queue. The manual page for the Unix listen() system
call should have more details. Check your OS documentation for the maximum value for this variable.
back_log cannot be set higher than your operating system limit
实际上它说在有大量连接时候,可能出现这样的问题,这里使用了一个short time来描述,也明确告诉你这个
参数和 Unix listen() system调用有关。
MYSQL listen 函数调用栈为
1、max_user_connections
max_user_connections这个参数是单个用户允许连接的最大会话数量,在建立用户的时候也有类似的限制,这里仅仅说的是这个参数
下面是官方文档说明:
The maximum number of simultaneous connections permitted to any given MySQL user account. A
value of 0 (the default) means “no limit.”
This variable has a global value that can be set at server startup or runtime. It also has a read-only
session value that indicates the effective simultaneous-connection limit that applies to the account
associated with the current session. The session value is initialized as follows:
? If the user account has a nonzero MAX_USER_CONNECTIONS resource limit, the session
max_user_connections value is set to that limit.
? Otherwise, the session max_user_connections value is set to the global value.
报错如下:
mysql: [Warning] Using a password on the command line interface can be insecure.
ERROR 1203 (42000): User root already has more than 'max_user_connections' active connections
2、max_connections
max_connections:这个参数是MYSQL服务端允许的最大连接会话数量,没什么好说的
下面是官方文档说明:
The maximum permitted number of simultaneous client connections. By default, this is 151. See
Section B.5.2.7, “Too many connections”, for more information.
Increasing this value increases the number of file descriptors that mysqld requires. If the required
number of descriptors are not available, the server reduces the value of max_connections. See
Section 9.4.3.1, “How MySQL Opens and Closes Tables”, for comments on file descriptor limits.
测试也非常简单报错如下:
[root@testmy ~]# /mysqldata/mysql5.7/bin/mysql --socket=/mysqldata/mysql5.7/mysqld3307.sock -utestmy -pGelc123123
mysql: [Warning] Using a password on the command line interface can be insecure.
ERROR 1040 (HY000): Too many connections
3、Max_used_connections 、Max_used_connections_time
这里还大概说一下
mysql> show global status like '%max%';
+-----------------------------------+---------------------+
| Variable_name | Value |
+-----------------------------------+---------------------+
| Max_used_connections | 7 |
| Max_used_connections_time | 2017-05-10 17:10:56 |
这两个状态说的是MYSQL SERVER自上次启动起来最大连接数量和发生的时间,和上面讲参数没任何关系。
? Max_used_connections
The maximum number of connections that have been in use simultaneously since the server started.
? Max_used_connections_time
The time at which Max_used_connections reached its current value. This variable was added in
MySQL 5.7.5
4、back_log
back_log:这个参数的解释相对于比较复杂和难以理解,难以理解是因为大多DBA对LINUX下C编程不熟悉,
这个参数说的就是sokcet编程中的listen调用的时候使用形参back_log
函数原型
int listen(int sockfd, int backlog);
man page中描述:
DESCRIPTION
listen() marks the socket referred to by sockfd as a passive socket, that is, as a socket that will be used to accept incoming connection requests using accept(2).
The sockfd argument is a file descriptor that refers to a socket of type SOCK_STREAM or SOCK_SEQPACKET.
The backlog argument defines the maximum length to which the queue of pending connections for sockfd may grow. If a connection request arrives when the queue is full, the client may receive an error with
an indication of ECONNREFUSED or, if the underlying protocol supports retransmission, the request may be ignored so that a later reattempt at connection succeeds.
RETURN VALUE
On success, zero is returned. On error, -1 is returned, and errno is set appropriately.
sockfd没什么好说的create的时候返回的scoket文件描述符,这里的backlog实际上是一个未决连接的一个队列,如果超过可能值会返回ECONNREFUSED的一个错误,但是如果底层协议支持retransmission,
,这个错误将被忽略然后再次尝试知道成功。它取决于LINUX系统设置/proc/sys/net/core/somaxconn和函数backlog的小值当然LINUX系统默认这个值是128.
下面是MYSQL官方文档描述:
The number of outstanding connection requests MySQL can have. This comes into play when the
main MySQL thread gets very many connection requests in a very short time. It then takes some
time (although very little) for the main thread to check the connection and start a new thread. The
back_log value indicates how many requests can be stacked during this short time before MySQL
momentarily stops answering new requests. You need to increase this only if you expect a large number
of connections in a short period of time.
In other words, this value is the size of the listen queue for incoming TCP/IP connections. Your operating
system has its own limit on the size of this queue. The manual page for the Unix listen() system
call should have more details. Check your OS documentation for the maximum value for this variable.
back_log cannot be set higher than your operating system limit
实际上它说在有大量连接时候,可能出现这样的问题,这里使用了一个short time来描述,也明确告诉你这个
参数和 Unix listen() system调用有关。
MYSQL listen 函数调用栈为
点击(此处)折叠或打开
免责声明:
① 本站未注明“稿件来源”的信息均来自网络整理。其文字、图片和音视频稿件的所属权归原作者所有。本站收集整理出于非商业性的教育和科研之目的,并不意味着本站赞同其观点或证实其内容的真实性。仅作为临时的测试数据,供内部测试之用。本站并未授权任何人以任何方式主动获取本站任何信息。
② 本站未注明“稿件来源”的临时测试数据将在测试完成后最终做删除处理。有问题或投稿请发送至: 邮箱/279061341@qq.com QQ/279061341
MYSQL max_user_connections back_log max_connections参数和Max_used_connections
下载Word文档到电脑,方便收藏和打印~
下载Word文档
猜你喜欢
MySQL存储过程输入参数,输出参数和输入输出参数是什么
这篇“MySQL存储过程输入参数,输出参数和输入输出参数是什么”文章的知识点大部分人都不太理解,所以小编给大家总结了以下内容,内容详细,步骤清晰,具有一定的借鉴价值,希望大家阅读完这篇文章能有所收获,下面我们一起来看看这篇“MySQL存储过
2023-07-02
2024-04-02
MySQL存储过程in、out和inout参数示例和总结
存储过程
1.创建存储过程并查看全局变量mysql> create database yy;
Query OK, 1 row affected (0.00 sec)mysql> use yy;
Database changed
mysql>
2022-05-13
2024-04-02
2024-04-02
2024-04-02
Linux下如何查看nginx、apache、mysql和php的编译参数
今天小编给大家分享一下Linux下如何查看nginx、apache、mysql和php的编译参数的相关知识点,内容详细,逻辑清晰,相信大部分人都还太了解这方面的知识,所以分享这篇文章给大家参考一下,希望大家阅读完这篇文章后有所收获,下面我们
2023-07-04
2024-04-02
mysql存储过程之参数(IN,OUT或INOUT)的区别和简单示例
在实际应用中,开发的存储过程几乎都需要参数,就是这些参数,使得存储过程更加灵活和有用。 在mysql中,参数有三种模式:IN,OUT或INOUT: IN - 是默认模式。在存储过程中定义IN参数时,调用程序必须将参数传递给存储过程。 另外,IN参数的值被保
2020-03-26
如何实现MySQL底层优化:参数配置和调整的最佳实践
如何实现MySQL底层优化:参数配置和调整的最佳实践摘要:MySQL是最常用的开源关系型数据库管理系统之一,其性能和稳定性对于大多数企业至关重要。然而,要充分发挥MySQL的潜力,需要进行一些底层优化。本文将介绍一些常用的参数配置和调整的最
2023-11-08
如果我跳过第四个和第五个参数,即分隔符和位数,MySQL EXPORT_SET() 函数的输出会发生什么?
我们知道第五个参数的默认值(即位数)是 64,因此如果我们不在第五个参数上指定任何值,MySQL 将检查最多 64 位的位并生成结果。然而,在跳过第四个参数(即分隔符)时,MySQL 将在显示输出时使用逗号 (,) 作为分隔符。示例mysq
2023-10-22
2024-04-02
编程热搜
[mysql]mysql8修改root密码
use mysqlselect * from user where user="root";update user set password=password("mysql@2020") where user="root";ERROR 1064 (42000)MySQL专题3之MySQL管理
1、启动以及关闭MySQL服务器- 首先,我们需要通过以下命令来检查MySQL服务器是否已经启动:ps -ef | grep mysqld- 如果MySQL已经启动,以上命令将输出mysql进程列表,如果mysql未启动,你可以使用以下
编程资源站
- 资料下载
- 历年试题