The maximum number of connections for MySQL defaults to 100, this value is not enough for concurrent connections to many database applications, when the connection request is greater than the default number of connections, there will be errors can not connect to the database, so we need to make it a bit more appropriate, there are two ways to modify the maximum number of connections, One is to modify the Safe_mysqld, the other is to modify the original code directly 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 MySQL's original code,
Into the inside of the SQL directory modification mysqld.cc find 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.