MySQL's maximum number of connections by default is 100, this value for many concurrent connections to the database application is not enough, when the connection request is greater than the default number of connections, there will be unable to connect to the database error, so we need to make it appropriate to the larger,
There are two ways to modify the maximum number of connections, one is to modify the Safe_mysqld, the other is to directly modify the original code and recompile. Here are two ways to do this:
1. Modify Safe_mysqld
Find Safe_mysqld edit it, find the two lines where the mysqld starts, and then add the arguments back:
-O max_connections=1000
For example: (The previous---is the original content, and +++ is modified)
---safe_mysqld.orig Mon Sep 25 09:34:01 2000
+++ Safe_mysqld Sun SEP 24 16:56:46 2000
@@ -109,10 +109,10 @@
if test "$#"-eq 0
Then
Nohup $ledir/mysqld--basedir= $MY _basedir_version--datadir= $DATADIR \
---skip-locking >> $err _log 2>&1
+--skip-locking-o max_connections=1000 >> $err _log 2>&1
Else
Nohup $ledir/mysqld--basedir= $MY _basedir_version--datadir= $DATADIR \
---skip-locking "$@" >> $err _log 2>&1
+--skip-locking "$@"-o max_connections=1000 >> $err _log 2>&1
Fi
if test! -F $pid _file # This is removed if normal shutdown
Then
Then shut down MySQL and restart it, with
/mysqladmin Path/mysqladmin-uroot-p variables
Enter the password for the root database account to see
| max_connections | 1000 |
That the new changes have taken effect.
2. Modify the original code
Unlock the original MySQL code, into the inside of the SQL directory modification mysqld.cc found the following line:
{"Max_connections", (long*) &max_connections,100,1,16384,0,1},
Change it to:
{"Max_connections", (long*) &max_connections,1000,1,16384,0,1},
Save to exit, and then./configure Make;make Install can achieve the same effect.