Get the App
SLTechnology News&Howtos  ›  Database  › 

How to set the maximum number of connections in mysql

Shulou Source: shulou.com Published: 2022-05-31 20:44:41 09月18日 Update

This article introduces how to set the maximum number of connections in mysql. The content is very detailed. Interested friends can use it for reference. I hope it will be helpful to you.

The method of setting the maximum number of connections in mysql

After the MYSQL database installation is completed, the default maximum number of connections is 100. generally, the number of connections to a slightly larger traffic or website is far from enough. There are two ways to increase the default number of MYSQL connections.

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 modify it to restart MYSQL in the max_connections=1000 service to www.2cto.com.

Method 2: the maximum number of connections for MySQL is 100 client login by default: mysql-uusername-ppassword

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

Displays the currently running Query:mysql > show processlist

Show current status: mysql > show status

Exit the client: mysql > exit

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

Method 3: take the manual compiled version of mysql 5.0.33 below centos 4.4 as an example:

Vi / usr/local/mysql/bin/mysqld_safe

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

-O max_connections=1500 www.2cto.com

Specifically, it is the following location:

To specify in the scarlet letter:

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

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

Max_connections 1500 means that the new changes have come into effect.

There's another way, www.2cto.com.

Modify the original code:

Unlock the original code of MySQL, enter the sql directory inside and modify d.cc to 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, and then. / configure; make;make install can get the same effect.

On how to set the maximum number of connections in mysql to share here, I hope the above content can be of some help to you, can learn more knowledge. If you think the article is good, you can share it for more people to see.

Tags: Maximum method code content customer client more directory face help good one line not enough two location interest parameter password boy buddy Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno macOS Xiaomi MariaDB Huawei Shulou Tech Info