How to modify the maximum number of connections of MYSQL

Source: Internet
Author: User
Tags mysql code

Mysql-uusername-ppassword
Mysqladmin-uroot-pwshengzhan variables;
The maximum number of connections in 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 | find "max_con"
After the MYSQL database is installed, the default maximum number of connections is 100. Generally, the number of connections to forums or websites with a higher traffic is far from enough. There are two ways to increase the default number of connections to MYSQL.
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 *) amp; 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 *) amp; 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.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.