----查看max_user_connections 默认值

  MySQL> show variables like 'max_user_connections';
+----------------------+-------+
| Variable_name | Value |
+----------------------+-------+
| max_user_connections | |
+----------------------+-------+ row in set (0.00 sec) ---设置 max_user_connections
mysql> set @@global.max_user_connections=; Query OK, rows affected (0.03 sec)
mysql> select @@max_user_connections;
+------------------------+
| @@max_user_connections |
+------------------------+
| |
+------------------------+
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 (): 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
Server version: 5.6.-enterprise-commercial-advanced MySQL Enterprise Server - Advanced Edition (Commercial)
Copyright (c) , , 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 |
+-------------------+
| |
+-------------------+
row in set (0.00 sec)
mysql> set @@global.max_connections=;
Query OK, rows affected (0.00 sec)
mysql> select @@max_connections;
+-------------------+
| @@max_connections |
+-------------------+
| |
+-------------------+
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 (HY000): Too many connections
[root@dg ~]# mysql -uu2 -pu2
Warning: Using a password on the command line interface can be insecure.
ERROR (HY000): Too many connections 实验完毕后,改回原来的参数
mysql> set @@global.max_user_connections=;
Query OK, rows affected (0.00 sec) mysql> select @@max_user_connections;
+------------------------+
| @@max_user_connections |
+------------------------+
| |
+------------------------+
row in set (0.00 sec)
mysql> set @@global.max_connections=;
Query OK, rows affected (0.00 sec)
mysql> select @@max_connections;
+-------------------+
| @@max_connections |
+-------------------+
| |
+-------------------+
row in set (0.00 sec) 结论: max_user_connections:限制每个用户的session连接个数,例如max_user_connections= ,那么用户u1只能连接的session数为1,如果还有用户u2,还是可以连接,但是连接数仍然为1
max_connections :是对整个服务器的用户限制,整个服务器只能开这么多session,而不考虑用户!

mysql 的max_connections和max_user_connections 的区别的更多相关文章

  1. mysql中max_connections与max_user_connections使用区别

    问题描述:把max_connections和max_user_connections参数进行分析测试,顾名思义,max_connections就是负责数据库全局的连接数,max_user_connec ...

  2. mysql实例的连接数max_user_connections 和max_connections 配置的那些事

    今天在查线上问题时,通过phpMyAdmin来进行DML操作,发现比平时慢多了,就各种进原因. 项目的场景是一个mysql实例中创建了多个数据库,猜想可能是相互影响所致. 然后,查询线上Mysql数据 ...

  3. 用count(*)还是count(列名) || Mysql中的count()与sum()区别

    Mysql中的count()与sum()区别   首先创建个表说明问题 CREATE TABLE `result` (   `name` varchar(20) default NULL,   `su ...

  4. 第三章(附)mysql表类型MyISAM和InnoDB区别(决定了是否支持事务)

    mysql表类型MyISAM和InnoDB区别 MyISAM:这个是默认类型,它是基于传统的ISAM类型,ISAM是Indexed Sequential Access Method (有索引的顺序访问 ...

  5. (转)MySQL中In与Exists的区别

    背景:总结mysql相关的知识点. 如果A表有n条记录,那么exists查询就是将这n条记录逐条取出,然后判断n遍exists条件. select * from user where exists s ...

  6. MySQL中interactive_timeout和wait_timeout的区别【转】

    在用mysql客户端对数据库进行操作时,打开终端窗口,如果一段时间没有操作,再次操作时,常常会报如下错误: ERROR 2013 (HY000): Lost connection to MySQL s ...

  7. Mysql中函数和存储过程的区别

    Mysql中函数和存储过程的区别 存储过程: 1.       可以写sql语句 2.       inout,out构造返回值 3.       调用:call:存储过程名称 4.       可以 ...

  8. MySQL存储过程中的3种循环,存储过程的基本语法,ORACLE与MYSQL的存储过程/函数的使用区别,退出存储过程方法

    在MySQL存储过程的语句中有三个标准的循环方式:WHILE循环,LOOP循环以及REPEAT循环.还有一种非标准的循环方式:GOTO,不过这种循环方式最好别用,很容易引起程序的混乱,在这里就不错具体 ...

  9. [转]Mysql几种索引类型的区别及适用情况

    此为转载文章,仅做记录使用,方便日后查看,原文链接:https://www.cnblogs.com/yuan-shuai/p/3225417.html Mysql几种索引类型的区别及适用情况   如大 ...

随机推荐

  1. iOS开发技巧-2

    1,打印View所有子视图 po [[self view]recursiveDescription] 2,layoutSubviews调用的调用时机 * 当视图第一次显示的时候会被调用 * 当这个视图 ...

  2. win10 Unistack 服务组 占用资源如何解决

    开始菜单>设置>隐私,隐私界面的左侧栏目,找最后一个“后台应用”,把后台运行的应用全部关掉即可

  3. [windows操作系统]目录和文件相关操作

    1.导出目录的树形结构到文本文件 tree /F d:\dir1 > d:\tree.txt 就是将d:\dir1的目录结构以树状形式输出报告到文件tree.txt中. 效果是这样的:

  4. CSS之过渡简单应用—日落西山

    代码: <!DOCTYPE html><html><head> <title>日落西山</title> <meta charset=& ...

  5. undefined reference to `Spreadsheet::staticMetaObject'

    <C++ GUI Qt 4 编程>学习 一.遇到的问题 在学完第4章后,Spreasheet程序也已经写好了.在用 FindDialog 搜索时发现没有效果. 二.解决过程 调试跟踪代码, ...

  6. JSTL(1.1)的配置

    1.查看你的项目中web.xml实际配置的servlet版本号? 2. servlet2.4所需要的jstl版本是1.1,所以上网下载jstl(1.1)的2个jar包,然后把这个2个jar包拷贝到你自 ...

  7. C语言程序设计第5堂作业

    一.本次课学习主要内容及知识结构点: 二.实验内容:(60分) 1. 求奇数和.输入一批正整数(以零或负数为结束标志),求其中的奇数和.试编写相应程序. 2. 展开式求和.输入一个实数 x,计算并输出 ...

  8. .NET微信模拟登录及{base_resp:{ret:-4,err_msg:nvalid referrer}}的解决办法

    12年的时候写了些关于微信开发的内容,当时看好这个东西,可惜当时腾讯开放的权限太少,之后的一年多时间没有太关注了. 现在又要重新开始微信开发的阵容了,微信只是个入口,微网站才是趋势. 我是个水货,所以 ...

  9. 基于KNN的newsgroup 18828文本分类器的Python实现

    还是同前一篇作为学习入门. 1. KNN算法描述: step1: 文本向量化表示,计算特征词的TF-IDF值 step2: 新文本到达后,根据特征词确定文本的向量 step3 : 在训练文本集中选出与 ...

  10. Quartz Core框架之CALayer

    1.继承链:NSObject 2.创建一个layer (1)+ (instancetype)layer :创建和返回一个layer实例对象 (2)- (instancetype)init :返回一个初 ...