mysql最大连接数试验
mysql 最大 连接数 试验
2023-09-14 08:59:31 时间
一、试验基础环境配置
1、查看当前数据库的最大连接数
mysql> show global variables like '%connect%'; +--------------------------+-----------------+ | Variable_name | Value | +--------------------------+-----------------+ | character_set_connection | utf8 | | collation_connection | utf8_general_ci | | connect_timeout | 10 | | init_connect | | | max_connect_errors | 10 | | max_connections | 160 | | max_user_connections | 0 | +--------------------------+-----------------+ 7 rows in set (0.00 sec)
2、设置全局变量max_connections为3(基于试验目的,做测试)
mysql> set global max_connections=3; Query OK, 0 rows affected (0.01 sec)
3、查看设置是否生效.max_connections已经设置为3.
mysql> show global variables like '%connect%'; +--------------------------+-----------------+ | Variable_name | Value | +--------------------------+-----------------+ | character_set_connection | utf8 | | collation_connection | utf8_general_ci | | connect_timeout | 10 | | init_connect | | | max_connect_errors | 10 | | max_connections | 3 | | max_user_connections | 0 | +--------------------------+-----------------+ 7 rows in set (0.00 sec)
4、退出当前登陆,再次登陆查看是否生效.
mysql> exit Bye C:\Users\ArcerZhang>mysql -uroot -parcerzhang Welcome to the MySQL monitor. Commands end with ; or \g. Your MySQL connection id is 3 Server version: 5.5.28 MySQL Community Server (GPL) Copyright (c) 2000, 2012, Oracle and/or its affiliates. All rights reserved. Oracle is a registered trademark of Oracle Corporation and/or its affiliates. Other names may be trademarks of their respective owners. Type 'help;' or '\h' for help. Type '\c' to clear the current input statement. mysql> show global variables like '%connect%'; +--------------------------+-----------------+ | Variable_name | Value | +--------------------------+-----------------+ | character_set_connection | utf8 | | collation_connection | utf8_general_ci | | connect_timeout | 10 | | init_connect | | | max_connect_errors | 10 | | max_connections | 3 | | max_user_connections | 0 | +--------------------------+-----------------+ 7 rows in set (0.00 sec)
二、查看当前数据库连接数
mysql> use arcerzhangdb; Database changed mysql> show processlist; +----+------+-----------------+--------------+---------+------+-------+------------------+ | Id | User | Host | db | Command | Time | State | Info | +----+------+-----------------+--------------+---------+------+-------+------------------+ | 3 | root | localhost:53232 | arcerzhangdb | Query | 0 | NULL | show processlist | +----+------+-----------------+--------------+---------+------+-------+------------------+ 1 row in set (0.00 sec)
三、分别打开第二个、第三个、第四个、第五个CMD窗口登录数据库
C:\Users\ArcerZhang>mysql -uroot -parcerzhang Welcome to the MySQL monitor. Commands end with ; or \g. Your MySQL connection id is 4 Server version: 5.5.28 MySQL Community Server (GPL) Copyright (c) 2000, 2012, Oracle and/or its affiliates. All rights reserved. Oracle is a registered trademark of Oracle Corporation and/or its affiliates. Other names may be trademarks of their respective owners. Type 'help;' or '\h' for help. Type '\c' to clear the current input statement. mysql> use arcerzhangdb; Database changed mysql> show tables; +------------------------+ | Tables_in_arcerzhangdb | +------------------------+ | inno_tab | | t | | t_myisam | | tablespace_test | | tt | | ttt | +------------------------+ 6 rows in set (0.00 sec) mysql> desc t; +-------+-------------+------+-----+---------+-------+ | Field | Type | Null | Key | Default | Extra | +-------+-------------+------+-----+---------+-------+ | id | int(11) | NO | PRI | 0 | | | name | varchar(10) | YES | | NULL | | +-------+-------------+------+-----+---------+-------+ 2 rows in set (0.12 sec)
mysql> show processlist; +----+------+-----------------+--------------+---------+------+-------+------------------+ | Id | User | Host | db | Command | Time | State | Info | +----+------+-----------------+--------------+---------+------+-------+------------------+ | 3 | root | localhost:53232 | arcerzhangdb | Query | 0 | NULL | show processlist | | 4 | root | localhost:53251 | arcerzhangdb | Sleep | 6 | | NULL | +----+------+-----------------+--------------+---------+------+-------+------------------+ 2 rows in set (0.00 sec)
C:\Users\ArcerZhang>mysql -uroot -parcerzhang Welcome to the MySQL monitor. Commands end with ; or \g. Your MySQL connection id is 5 Server version: 5.5.28 MySQL Community Server (GPL) Copyright (c) 2000, 2012, Oracle and/or its affiliates. All rights reserved. Oracle is a registered trademark of Oracle Corporation and/or its affiliates. Other names may be trademarks of their respective owners. Type 'help;' or '\h' for help. Type '\c' to clear the current input statement. mysql> use arcerzhangdb; Database changed mysql> select * from tt; +------+------+ | id | msg | +------+------+ | 1 | a | | 2 | b | | 3 | c | | 4 | d | | 5 | e | | 1000 | f | +------+------+ 6 rows in set (0.06 sec) mysql>
mysql> show processlist; +----+------+-----------------+--------------+---------+------+-------+------------------+ | Id | User | Host | db | Command | Time | State | Info | +----+------+-----------------+--------------+---------+------+-------+------------------+ | 3 | root | localhost:53232 | arcerzhangdb | Query | 0 | NULL | show processlist | | 4 | root | localhost:53251 | arcerzhangdb | Sleep | 43 | | NULL | | 5 | root | localhost:53264 | arcerzhangdb | Sleep | 5 | | NULL | +----+------+-----------------+--------------+---------+------+-------+------------------+ 3 rows in set (0.00 sec)
C:\Users\ArcerZhang>mysql -uroot -parcerzhang Welcome to the MySQL monitor. Commands end with ; or \g. Your MySQL connection id is 6 Server version: 5.5.28 MySQL Community Server (GPL) Copyright (c) 2000, 2012, Oracle and/or its affiliates. All rights reserved. Oracle is a registered trademark of Oracle Corporation and/or its affiliates. Other names may be trademarks of their respective owners. Type 'help;' or '\h' for help. Type '\c' to clear the current input statement. mysql> use arcerzhangdb; Database changed mysql> show tables; +------------------------+ | Tables_in_arcerzhangdb | +------------------------+ | inno_tab | | t | | t_myisam | | tablespace_test | | tt | | ttt | +------------------------+ 6 rows in set (0.00 sec) mysql> select * from ttt; +----+------+ | id | msg | +----+------+ | 1 | a | +----+------+ 1 row in set (0.07 sec) mysql>
mysql> show processlist; +----+------+-----------------+--------------+---------+------+-------+------------------+ | Id | User | Host | db | Command | Time | State | Info | +----+------+-----------------+--------------+---------+------+-------+------------------+ | 3 | root | localhost:53232 | arcerzhangdb | Query | 0 | NULL | show processlist | | 4 | root | localhost:53251 | arcerzhangdb | Sleep | 97 | | NULL | | 5 | root | localhost:53264 | arcerzhangdb | Sleep | 59 | | NULL | | 6 | root | localhost:53274 | arcerzhangdb | Sleep | 5 | | NULL | +----+------+-----------------+--------------+---------+------+-------+------------------+ 4 rows in set (0.00 sec)
Microsoft Windows [版本 10.0.10586] (c) 2015 Microsoft Corporation。保留所有权利。 C:\Users\ArcerZhang>mysql -uroot -parcerzhang ERROR 1040 (HY000): Too many connections C:\Users\ArcerZhang>
四、结论
第一个连接窗口为初始窗口,或者说叫做监控窗口.
第二个连接窗口应该算是我们设置max_connections=3后第一个真正意义上的连接用户.
第三个连接窗口应该算是我们设置max_connections=3后第二个真正意义上的连接用户.
第四个连接窗口应该算是我们设置max_connections=3后第三个真正意义上的连接用户.
所以当打开第五个窗口的时候,会报如下错误:
C:\Users\ArcerZhang>mysql -uroot -parcerzhang ERROR 1040 (HY000): Too many connections
相关文章
- MySQL的MaxID:获取最大的唯一ID(mysql最大id)
- 优化MySQL表的索引使用方法(mysql表的索引)
- 据MySQL实时数据库连接:极速体验(mysql实时连接数)
- MySQL获取最大ID的方法(mysql获取最大的id)
- MySQL中如何实现多字段的分组查询(mysql多个字段分组)
- MySQL 操作:最佳实践–最大SQL(mysql最大sql)
- MySQL中快速查找字符位置的技巧(mysql查找字符位置)
- 的应用MySQL在服务器端的强大运用(mysql在服务器端)
- 构建完善的省市区MySQL数据库(省市区数据库mysql)
- MySQL实时数据同步技术研究(mysql数据实时同步)
- 查询MySQL服务器的连接数量(mysql连接数查询)
- 如何在MySQL中设置最大连接池数?(mysql最大连接池数)
- 如何检测和优化MySQL并发连接数(查看mysql并发数)
- 如何修改MySQL的最大连接数?(mysql修改最大连接数)
- 值【MySQL 获取每个分组中的最大值】(mysql分组最大)
- MySQL调整配置达到最大连接数(mysql配置最大连接数)
- MySQL高性能之路:提高并发连接数(mysql 并发 连接数)
- MySQL多字段同时更新技巧(mysql更新多个字段值)
- 大小Mysql最大数据表大小探究(mysql最大表)
- C语言操纵MySQL中字段的实现方式(c 与mysql字段对应)
- MySQL如何查询最大时间值(mysql中去最大时间)
- MySQL启动成功(mysql 一起正在启动)
- MySQL数据表一行最大长度限制是多少(mysql 一行最大长度)
- MySQL单行最大字符数为65535(mysql一行65535)
- MySQL限制连接数解决方法(mysql不充许连接)
- MySQL上传限制你知道最大容量吗(mysql上传最大限制吗)