Three commonly used methods to modify mysql maximum number of connections

Source: Internet
Author: User
Keywords Network programming Mysql tutorial
Tags based configuration connections default directory exit file find

After MYSQL database installation is complete, the default maximum number of connections is 100, the general flow slightly larger forums or websites this connection is not enough, increase the default number of MYSQL connections there are two

Method One: Enter the MYSQL installation directory Open MYSQL configuration file my.ini or my.cnf Find max_connections = 100 Modify max_connections = 1000 MYSQL Based restart the service

Method Two: The maximum number of MySQL connections is 100 Client login: mysql-uusername-ppassword

Set the new maximum number of connections to 200: mysql> set GLOBAL max_connections = 200

Display currently running Query: mysql> show processlist

Show the current status: mysql> show status

Exit the client: mysql> exit

Check the current maximum number of connections: mysqladmin-uusername-ppassword variables

Method three: CentOS 4.4 mysql 5.0.33 manual compiled version as an example:

vi / usr / local / mysql / bin / mysqld_safe

Find safe_mysqld edit it, find the mysqld start two lines, add the parameters in the back:

-O max_connections = 1500

The specific point is the following location:

Special 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 can be seen

max_connections 1500 That the new changes have taken effect.

There is also a way,

Modify the original code:

Unlock the MySQL source code, enter the sql directory inside 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 to:

{"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 and exit, then. / Configure; make; make install can get 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.