In the default mysql database status, it seems that the number of connections is 50, so if your website traffic is too large, it will cause the mysql connection to exceed the limit, next I will introduce how to modify the number of MySQL connections in linux and widows.
The procedure is as follows (applicable to both Windows and Linux platforms ):
A. log on to MySQL from the client and enter the user name and password.
B. At the MYSQL command prompt, set the new maximum number of connections to 500: mysql> set GLOBAL max_connections = 500.
C. display the currently running Query: mysql> show processlist
D. display the current MYSQL system parameter status: mysql> show status
E. exit the client: mysql> exit
To view the maximum number of connections, run the following command in the directory where mysqladmin is located: mysqladmin-username-password variables | find "max_con. You can also use the MYSQL parameter list in PHPMyadmin to view the maximum number of connections.
Disadvantage: After the computer is restarted or MySQL, the maximum number of connections is reset to the initial value. You need to reset the value.
2. Modify the my. ini or my. cnf file method (MySQL needs to be restarted). For details, refer to the MySQL configuration template in the same directory (small memory, large memory, and ultra-large memory)
The following mysql 5.0.33 manual version in centos 4.4 is used 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.
In Windows:
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.
Linux console:
Open the my. cnf file: vi/etc/my. cnf
In the [mysqld] section, modify the value of max_connections to a set value.
Tianyuan note: the source and version of MYSQL may be different (the final installation results of MySQL + IIS and PHP + Apache + MySQL in Windows are almost different), my. the path of the INI file may be somewhat different, my. ini may retain a copy in the C: Windows directory that needs to be modified at the same time.
Note: In windows, max_connections cannot open more files than windows.