How to increase the maximum number of connections in MYSQL

Source: Internet
Author: User

Introduction: mysql databaseIt is a database system with good application. With the development of technology, the workload of mysql database is also very large. At this time, the default number of connections is not enough, this requires increasing the number of connections to the mysql database. There are two ways to change the maximumConnectionsOne is to modify safe_mysqld, and the other is to directly modify the original code and re-compile it. The following two methods are described respectively:

1. Modify safe_mysqld

Find safe_mysqld and edit it. Find the two lines started by mysqld and add the following parameters:

-O max_connections = 1000

For example: (the preceding content 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

@-Random, 10 + random, 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

Disable mysql and restart it.

/Mysqladmin path/mysqladmin-uroot-p variables

Enter the password of the root database account.

| Max_connections | 1000 |

That is, the new change has taken effect.

2. 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", (long *) & max_connections, 1, 1 },

Change it:

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

Save the disk and exit./configure; make install to achieve the same effect.

The two methods summarized here can make mysql database work well. If you have more and better methods, please share them with us.

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.