上午刚工作10分左右,共事说在应用jira时呈现问题,具体截图如下:

通过上图的报错信息:定位为mysql数据库连接数的问题

解决办法:

1.登录mysql进行查看

Mysql –uroot –p123456mysql> show variables like'%max_connections%';+-----------------+-------+| Variable_name   | Value |+-----------------+-------+| max_connections | 151  |+-----------------+-------+1 row in set (0.00 sec)

很奇怪,最大连接数怎么是151呢,mysql默认的最大连接数不是100么?起初想一下可能是版本不同的问题,默认连接数也不同。为了确认mysql5.5.3默认的最大连接数为151,去mysql官网查看了一下:mysql默认的最大连接数为151,下限为1000

2.批改mysql默认的最大连接数为1000

在/etc/my.cnf文件中[mysqld]局部减少max_connections=1000,重启mysql服务,问题解决。

补充1:mysql其余版本默认的最大连接数

Mysql5.5 mysql5.6 mysql5.7:默认的最大连接数都是151,下限为:100000

Mysql5.1依据其小版本的不同,默认的最大连接数和可批改的连接数下限也有所不同

图片Mysql5.0版本:默认的最大连接数为100,下限为16384

补充2:批改mysql数据库默认的最大连接数

办法一:批改mysql的主配置文件/etc/my.cnf,[mysqld]局部增加“max_connections=1000(这个依据理论的须要来进行设置即可)”,重启mysql服务。

办法二:mysql客户端登录,通过命令行批改全局变量来进行批改

mysql -uroot -p123456mysql> set global_max_connections = 200;mysql> show processlist;mysql> show status;批改实现后进行查看,mysql的最大连接数mysql> show variables like '%max_connections%';+-----------------+-------+| Variable_name   | Value |+-----------------+-------+| max_connections | 1000  |+-----------------+-------+1 row in set (0.00 sec)

办法三:解开mysql源代码,进入外面的SQL目录批改mysqld.cc找到上面一行:

{"max_connections", OPT_MAX_CONNECTIONS,  "The number of simultaneous clients allowed.", (gptr*) &max_connections,  (gptr*) &max_connections, 0, GET_ULONG, REQUIRED_ARG, 100, 1, 16384, 0, 1,  0},  把它改为:  {"max_connections", OPT_MAX_CONNECTIONS,  "The number of simultaneous clients allowed.", (gptr*) &max_connections,  (gptr*) &max_connections, 0, GET_ULONG, REQUIRED_ARG, 1500, 1, 16384, 0, 1,  0},  保留退出,而后./configure ;make;make install能够取得同样的成果

办法四:通过批改mysqld_safe来批改mysql的连接数

编辑 mysqld_safe配置文件,找到如下内容:

then $NOHUP_NICENESS $ledir/$MYSQLD  $defaults --basedir=$MY_BASEDIR_VERSION  --datadir=$DATADIR $USER_OPTION  --pid-file=$pid_file  --skip-external-locking  -O max_connections=1500  >> $err_log 2>&1 else  eval "$NOHUP_NICENESS $ledir/$MYSQLD  $defaults --basedir=$MY_BASEDIR_VERSION  --datadir=$DATADIR $USER_OPTION  --pid-file=$pid_file  --skip-external-locking $args  -O max_connections=1500 >>  $err_log 2>&1"

红色行代表要增加的字段,保留退出并重启mysql服务。

起源 | https://blog.51cto.com/525007...