How to increase the number of MYSQL database connections how to increase the number of MySQL database connections. after the MYSQL database is installed, the default number of connections is 100. this number of connections is not enough for forums or websites with a slightly larger traffic, so how can we increase the default number of MYSQL connections? Here we will introduce you to the specific methods and Operation steps!
Method 1: Go to the MySQL installation directory and open the MYSQL configuration file my. ini or my. cnf to find max_connections = 100 and change it to max_connections = 1000 to restart MYSQL.
Method 2: The maximum number of connections of MySQL is 100 by default. client logon: mysql-uusername-ppassword
Set the new maximum number of connections to 200: MySQL> set GLOBAL max_connections = 200
Display the currently running Query: MySQL> show processlist
Display Current status: MySQL> show status
Exit the client: MySQL> exit
View the current maximum number of connections: MySQLadmin-uusername-ppassword variables
Method 3: Take MySQL 5.0.33 in centos 4.4 as an example:
Vi/usr/local/MySQL/bin/mysqld_safe
Find safe_MySQLd and edit it. find the two lines started by mysqld and add the following parameters:
-O max_connections = 1500
The specific point is the following position:
Note in red:
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"
Save.
# Service MySQLd restart
#/Usr/local/MySQL/bin/mysqladmin-uroot-p variables
Enter the password of the root database account.
Max_connections 1500 indicates that the new change has taken effect.
There is another method,
Modify the original code:
Unlock the original MySQL code and go to the SQL directory to modify mysqld. cc. find the following line:
{"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 },
Change it:
{"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 },
Save the disk and exit./configure; make install to achieve the same effect.