上午刚工做10分左右,同事说在使用jira时出现问题,具体截图以下:html
经过上图的报错信息:定位为mysql数据库链接数的问题mysql
解决方法:
sql
1.登陆mysql进行查看 Mysql –uroot –p123456 mysql> 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,上限为:100000bash
Mysql5.1根据其小版本的不一样,默认的最大链接数和可修改的链接数上限也有所不一样ide
Mysql5.0版本:默认的最大链接数为100,上限为16384ui
补充2:修改mysql数据库默认的最大链接数spa
方法一:修改mysql的主配置文件/etc/my.cnf,[mysqld]部分添加“max_connections=1000(这个根据实际的须要来进行设置便可)”,重启mysql服务。
方法二:mysql客户端登陆,经过命令行修改全局变量来进行修改.net
mysql -uroot -p123456 mysql> 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服务。
参考文章:http://blog.chinaunix.net/uid-20592013-id-94956.html
http://blog.csdn.net/tongle_deng/article/details/6932733