How to set the maximum number of connections of MySQL
MySQLAfter the database is installed, the defaultMax connectionThe number is 100. Generally, forum orWebsiteThis number of connections is far from enough. There are two ways 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 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 originalCode:
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; make install to achieve the same effect.
MySQLAfter the database is installed, the defaultMax connectionThe number is 100. Generally, forum orWebsiteThis number of connections is far from enough. There are two ways 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 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; make install to achieve the same effect.