Two ways to increase the maximum number of connections in MySQL

Source: Internet
Author: User

The maximum number of connections for MySQL defaults to 100, this value is not enough for concurrent connections to many database applications, when the connection request is greater than the default number of connections, there will be errors can not connect to the database, so we need to make it a bit more appropriate, there are two ways to modify the maximum number of connections, One is to modify the Safe_mysqld, the other is to modify the original code directly and recompile. Here are two ways to do this:

1. Modify Safe_mysqld

Find Safe_mysqld edit it, find the two lines where the mysqld starts, and then add the arguments back:

-O max_connections=1000

For example: (The previous---is the original content, and +++ is modified)

---safe_mysqld.orig Mon Sep 25 09:34:01 2000

+++ Safe_mysqld Sun SEP 24 16:56:46 2000

@@ -109,10 +109,10 @@

if test "$#"-eq 0

Then

Nohup $ledir/mysqld--basedir= $MY _basedir_version--datadir= $DATADIR

---skip-locking >> $err _log 2>&1

+--skip-locking-o max_connections=1000 >> $err _log 2>&1

Else

Nohup $ledir/mysqld--basedir= $MY _basedir_version--datadir= $DATADIR

---skip-locking "$@" >> $err _log 2>&1

+--skip-locking "$@"-o max_connections=1000 >> $err _log 2>&1

Fi

if test! -F $pid _file # This is removed if normal shutdown

Then

Then shut down MySQL and restart it, with

/mysqladmin Path/mysqladmin-uroot-p variables

Enter the password for the root database account to see

| max_connections | 1000 |

That the new changes have taken effect.

2. Modify the original code

Unlock MySQL's original code,

Into the inside of the SQL directory modification mysqld.cc find the following line:

{"Max_connections", (long*) &max_connections,100,1,16384,0,1},

Change it to:

{"Max_connections", (long*) &max_connections,1000,1,16384,0,1},

Save to exit, and then./configure Make;make Install can achieve the same effect.



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.