Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to increase the maximum number of connections in MySql

2025-02-24 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >

Share

Shulou(Shulou.com)05/31 Report--

This article mainly introduces "how to increase the maximum number of connections in MySql". In daily operation, I believe many people have doubts about how to increase the maximum number of connections in MySql. The editor consulted all kinds of materials and sorted out simple and easy-to-use methods of operation. I hope it will be helpful for you to answer the questions of "how to increase the maximum number of connections in MySql"! Next, please follow the editor to study!

The maximum number of connections in mysql is 100 by default, which is not enough for database applications with many concurrent connections. When the connection request is greater than the default number of connections, there will be an error that the database cannot be connected, so we need to increase it appropriately.

There are two ways to change the maximum number of connections, one is to modify the safe_mysqld, and the other is to directly modify the original code and recompile. Let's introduce these two methods respectively:

1. Modify safe_mysqld

Find safe_mysqld and edit it, find the two lines where mysqld starts, and add parameters at the end:

-O max_connections=1000

For example: (the content preceded by-- is the original content, while + 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 close mysql and restart it, using the

/ path where mysqladmin is located / mysqladmin-uroot-p variables

After entering the password of the root database account, you can see

| | max_connections | 1000 | |

That is, the new changes have come into effect.

two。 Modify the original code

Unlock the original code of MySQL, enter the sql directory inside and modify mysqld.cc to find the following line:

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

Change it to:

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

Save and exit, and then. / configure; make;make install can get the same effect.

At this point, the study on "how to increase the maximum number of connections in MySql" is over. I hope to be able to solve your doubts. The collocation of theory and practice can better help you learn, go and try it! If you want to continue to learn more related knowledge, please continue to follow the website, the editor will continue to work hard to bring you more practical articles!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Database

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report