Correct modification of the maximum number of MySQL connections

Source: Internet
Author: User
Tags mysql code
The following articles mainly introduce three useful methods for correctly modifying the maximum number of MySQL connections. 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 a forum or website with a slightly larger traffic is far from enough. There are two ways to increase the default number of connections to MySQL. Method 1: Enter

The following articles mainly introduce three useful methods for correctly modifying the maximum number of MySQL connections. 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 a forum or website with a slightly larger traffic is far from enough. There are two ways to increase the default number of connections to MySQL. Method 1: Enter

The following articles mainly introduce three useful methods for correctly modifying the maximum number of MySQL connections. 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 a forum or website with a slightly larger 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 to MySQL is 100 by default. Client Logon:

 
 
  1. MySQL -uusername -ppassword

Set the maximum number of new MySQL connections to 200:

 
 
  1. MySQL> set GLOBAL max_connections=200

Display the currently running Query:

 
 
  1. MySQL> show processlist

Display Current status:

 
 
  1. 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:

 
 
  1. 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:

 
 
  1. -O max_connections=1500

The specific point is the following position:

Note in Red:

 
 
  1. then $NOHUP_NICENESS $ledir/$MySQLD
  2. $defaults --basedir=$MY_BASEDIR_VERSION
  3. --datadir=$DATADIR $USER_OPTION
  4. --pid-file=$pid_file
  5. --skip-external-locking
  6. -O max_connections=1500
  7. >> $err_log 2>&1 else
  8. eval "$NOHUP_NICENESS $ledir/$MySQLD
  9. $defaults --basedir=$MY_BASEDIR_VERSION
  10. --datadir=$DATADIR $USER_OPTION
  11. --pid-file=$pid_file
  12. --skip-external-locking $args
  13. -O max_connections=1500 >>
  14. $err_log 2>&1"

Save.

 
 
  1. # service MySQLd restart
  2. # /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:

 
 
  1. {"max_connections", OPT_MAX_CONNECTIONS,
  2. "The number of simultaneous clients allowed.", (gptr*) &max_connections,
  3. (gptr*) &max_connections, 0, GET_ULONG, REQUIRED_ARG, 100, 1, 16384, 0, 1,
  4. 0},

Change it:

 
 
  1. {"max_connections", OPT_MAX_CONNECTIONS,
  2. "The number of simultaneous clients allowed.", (gptr*) &max_connections,
  3. (gptr*) &max_connections, 0, GET_ULONG, REQUIRED_ARG, 1500, 1, 16384, 0, 1,
  4. 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.

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.