Www. oschina. netcodesnippet_222150_12958 we all know that after the MySQL database is installed, the default MySQL database has a maximum number of connections of 100. Generally, the number of connections to forums or websites with a slightly larger traffic is far from enough, there are two methods to increase the default number of MySQL connections. Method 1: Enter the MySQL installation project
Http://www.oschina.net/code/snippet_222150_12958 we all know that after the installation of the MySQL database, the default MySQL database, its maximum number of connections is 100, the general traffic is a little larger forum or website this number of connections is far from enough, there are two methods to increase the default number of MySQL connections. Method 1: Enter the MySQL installation project
Http://www.oschina.net/code/snippet_222150_12958
We all know that after the MySQL database is installed, the default MySQL database has a maximum number of connections of 100. Generally, the number of connections to forums or websites with a slightly larger traffic is far from enough, there are two methods to increase the default number of MySQL connections.
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 to MySQL is 100 by default. Client Logon:
MySQL -uusername -ppassword
Set the maximum number of new MySQL connections to 200:
MySQL>set GLOBALmax_connections=200
Display the currently running Query:
MySQL> show processlist
Display Current status:
MySQL> show status
Exit the client: MySQL> exit
View the maximum number of connections to MySQL: 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>&1else
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. The above content is an introduction to the three methods for modifying the maximum number of connections of MySQL. I hope you will find some gains.
Zookeeper