mysql 的max_connections和max_user_connections 的区别
发布日期:2021-09-16 04:38:47
浏览次数:34
分类:技术文章
本文共 2989 字,大约阅读时间需要 9 分钟。
----查看max_user_connections 默认值
mysql> show variables like 'max_user_connections';
+----------------------+-------+ | Variable_name | Value | +----------------------+-------+ | max_user_connections | 0 | +----------------------+-------+1 row in set (0.00 sec)
---设置 max_user_connections
mysql> set @@global.max_user_connections=1;Query OK, 0 rows affected (0.03 sec)
mysql> select @@max_user_connections; +------------------------+ | @@max_user_connections | +------------------------+ | 1 | +------------------------+ 1 row in set (0.00 sec) 上面参数设置完后窗口,要重新登陆一下root@dg ~]# mysql -uroot -pmysql
然后再开一个窗口登陆就会报如下错误: root@dg ~]# mysql -uroot -pmysql 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
另外在登陆一个用户u2,正常登陆,但是在登陆一个u2用户,就会报错: root@dg mysql]# mysql -uu2 -pu2 Warning: Using a password on the command line interface can be insecure. Welcome to the MySQL monitor. Commands end with ; or \g. Your MySQL connection id is 147 Server version: 5.6.27-enterprise-commercial-advanced MySQL Enterprise Server - Advanced Edition (Commercial) Copyright (c) 2000, 2015, 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.max_user_connections 针对用户设计的
下面我们来看看max_connections 的作用
mysql> select @@max_connections; +-------------------+ | @@max_connections | +-------------------+ | 151 | +-------------------+ 1 row in set (0.00 sec) mysql> set @@global.max_connections=2; Query OK, 0 rows affected (0.00 sec) mysql> select @@max_connections; +-------------------+ | @@max_connections | +-------------------+ | 2 | +-------------------+ 1 row in set (0.00 sec) 上面参数设置完后窗口,要重新登陆一下 [root@dg mysql]# mysql -uroot -pmysql 在开一个窗口session2正常登陆: [root@dg mysql]# mysql -uroot -pmysql 再开第三个窗口,session3 登陆的时候报错 [root@dg ~]# mysql -uroot -pmysql Warning: Using a password on the command line interface can be insecure. ERROR 1040 (HY000): Too many connections [root@dg ~]# mysql -uu2 -pu2 Warning: Using a password on the command line interface can be insecure. ERROR 1040 (HY000): Too many connections 实验完毕后,改回原来的参数 mysql> set @@global.max_user_connections=0; Query OK, 0 rows affected (0.00 sec) mysql> select @@max_user_connections; +------------------------+ | @@max_user_connections | +------------------------+ | 0 | +------------------------+ 1 row in set (0.00 sec) mysql> set @@global.max_connections=200; Query OK, 0 rows affected (0.00 sec) mysql> select @@max_connections; +-------------------+ | @@max_connections | +-------------------+ | 200 | +-------------------+ 1 row in set (0.00 sec) 结论:max_user_connections:限制每个用户的session连接个数,例如max_user_connections=1 ,那么用户u1只能连接的session数为1,如果还有用户u2,还是可以连接,但是连接数仍然为1
max_connections :是对整个服务器的用户限制,整个服务器只能开这么多session,而不考虑用户!转载地址:https://blog.csdn.net/wll_1017/article/details/51981349 如侵犯您的版权,请留言回复原文章的地址,我们会给您删除此文章,给您带来不便请您谅解!
发表评论
最新留言
不错!
[***.144.177.141]2024年04月17日 17时49分37秒
关于作者
喝酒易醉,品茶养心,人生如梦,品茶悟道,何以解忧?唯有杜康!
-- 愿君每日到此一游!
推荐文章
深入探讨Varnish缓存命中率
2019-04-27
Linux下文件如果没有权限不能被Apache访问
2019-04-27
Linux内核学习四库全书
2019-04-27
Linux内核模块编程入门
2019-04-27
使用Cacti监控你的网络Cacti的安装
2019-04-27
2011年6月编程语言关注度排行
2019-04-27
Varnish使用小结
2019-04-27
千万级并发HAproxy均衡负载系统介绍
2019-04-27
什么是A记录、MX记录、CNAME记录
2019-04-27
MongoDB简介
2019-04-27
Varnish purges 缓存清除
2019-04-27
Linux下redis安装部署
2019-04-27
水平切分与垂直切分
2019-04-27
MySQL引擎
2019-04-27
MySQL下的NoSQL解决方案HandlerSocket
2019-04-27
Apache服务器下使用 ab 命令进行压力测试
2019-04-27
查看Firefox中的缓存
2019-04-27
http header头设置反向代理不缓存
2019-04-27
配置MySQL主从复制
2019-04-27