At about 10 in the morning, my colleague said that there was a problem when using JIRA. The specific screenshots are as follows:

Error: The number of connections to the mysql database is faulty

Solutions:

1. Log in to the mysql database

Mysql -- uroot -- p123456 Mysql > show variables like'%max_connections%'; +-----------------+-------+ | Variable_name | Value | +-----------------+-------+ | max_connections | 151 | + -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- - + -- -- -- -- -- -- -- + 1 row in the set (0.00 SEC)Copy the code

Mysql default maximum number of connections is 100.

Later, I thought it might be different versions of the problem, the default connection number is also different.

The default maximum number of connections for mysql5.5.3 is 151, and the maximum number of connections is 100000.

2. Change the default maximum number of mysql connections to 1000

Add max_connections=1000 to [mysqld] /etc/my.cnf

Add 1: The default maximum number of connections of other mysql versions

Mysql5.5 mysql5.6 mysQL5.7: default maximum number of connections is 151, upper limit: 100000



The default maximum number of connections and the maximum number of connections that can be modified vary depending on the minor version of Mysql5.1



Mysql5.0: The default maximum number of connections is 100 and the upper limit is 16384



Add 2: Change the default maximum number of connections to the mysql database

Method 1: Modify the main mysql configuration file /etc/my.cnf, add max_connections=1000 to [mysqld], and restart the mysql service.

Method 2: Log in to the mysql client and modify global variables on the CLI

mysql -uroot -p123456
mysql> set global_max_connections = 200;
mysql> show processlist;
mysql> show status;
Copy the code

Check the maximum number of mysql connections after the modification

mysql> show variables like '%max_connections%'; +-----------------+-------+ | Variable_name | Value | +-----------------+-------+ | max_connections | 1000 | + -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- - + -- -- -- -- -- -- -- + 1 row in the set (0.00 SEC)Copy the code

Mysqld. cc = mysqld.cc = mysqld.cc = mysqld.cc = 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},
Copy the code

Change it to:

{"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},
Copy the code

Save exit, then./configure; make; Make install can get the same effect

Mysqld_safe = mysqLD_safe

Edit the mysqLD_Safe configuration file to find the following:

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"
Copy the code

Save the Settings, exit, and restart the mysql service.