Three easy-to-use solutions for correctly modifying MySQL maximum connection number

Source: Internet
Author: User
Tags mysql code

The following article mainly introduces the correct modification of MySQL maximum connection number of three easy to use scheme, we all know that MySQL database after installation, the default MySQL database, its maximum number of connections is 100, general traffic slightly larger forum or website this connection number is far from enough, There are two ways to increase the number of default MySQL connections.
Method One:
Go to MySQL install directory open mysql config file my.ini or my.cnf find max_connections=100 Modify for max_connections=1000 service to restart MySQL can
Method Two:
MySQL maximum number of connections by default is 100 client logon:
Copy Code

Set the new MySQL maximum number of connections to 200:
Mysql> Set GLOBAL max_connections=200

Mysql>show VARIABLES;

Mysql>show VARIABLES like ' max_% ';

Displays the currently running query:
Mysql> Show Processlist

How to query MySQL's connected number

Mysql>show full processlist;

Show current status:
Mysql> Show Status
Copy Code

Exit Client:mysql> Exit
View current MySQL max connections: Mysqladmin-uusername-ppassword variables

Method Three:
For example, the manual compilation version of the MySQL 5.0.33 below CentOS 4.4 illustrates:

Copy Code

Find Safe_mysqld edit it, find the two lines that mysqld started, and add the following parameters:

-O max_connections=1500
Copy Code

The specific point is the following position:
Special description in 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 _nice NESS $ledir/$MySQLD $defaults--basedir= $MY _basedir_version--datadir= $DATADIR $USER _option--pid-file= $pid _file--sk Ip-external-locking $args-o max_connections=1500 >> $err _log 2>&1 "
Copy Code


# service MySQLd Restart #/usr/local/mysql/bin/mysqladmin-uroot-p variables
Copy Code

Enter the password of the root database account to see
Max_connections 1500 that the new changes are in effect.
There is also a way to
Modify the original code:
To unlock the original MySQL code, go inside the SQL directory to modify to find the following line:

{"Max_connections", Opt_max_connections, "the number of simultaneous clients allowed.", (gptr*) &max_connections, (g ptr*) &max_connections, 0, Get_ulong, Required_arg, 100, 1, 16384, 0, 1, 0},
Copy Code

Change it to:

{"Max_connections", Opt_max_connections, "the number of simultaneous clients allowed.", (gptr*) &max_connections, (g ptr*) &max_connections, 0, Get_ulong, Required_arg, 1500, 1, 16384, 0, 1, 0},
Copy Code

Save to exit, then./con**ure; Make;make install can achieve the same effect. The above related content is to modify the MySQL maximum connection number of 3 ways to introduce, hope you can have some gains.

Original from the "Bit network", reproduced please keep the original link:

How do I query the number of MySQL connections??

How to query how many users MySQLServer is currently connected?? I am using the Windows operating system, the server is installed on another machine, I am the number of connected users that the client wants to get the server. Please let us know.

>show full processlist;

D:mysqlbin>mysqladmin Processlist-uroot-pgene

Sorry, I have a problem with the description. What I want to get is the number of clients that are connected to the server. With this show full processlist, the statement gets more than 10 records, and the record is duplicated, as you did above, the same user logged in it shows two records, and I want to get 1.
This command sees the host
To the host, redundancy is what you want.

View MySQL Connection number method 2010-06-09 13:031, view the details of all current connections:

Mysqladmin-uroot-proot processlist
D:\mysql\bin>mysqladmin-uroot-proot processlist
| Id | User | Host | db | Command | Time | State | Info |
| 591 | Root | localhost:3544 | BBS | Sleep | 25 | | |
| 701 | Root | localhost:3761 | | Uery | 0 | | Show Processlist |
2. View only the current number of MySQL connections (threads is the number of connections):

Mysqladmin-uroot-proot status
D:\mysql\bin>mysqladmin-uroot-proot status
uptime:2102 threads:3 questions:15531 Slow queries:0 opens:0 Flush tab
Les:1 Open tables:61 Queries per second avg:7.389
3. Modify MySQL maximum MySQL connection number:

Open My.ini, modify max_connections=100 (default = 100).

Three easy-to-use solutions for correctly modifying MySQL maximum connections

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: 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.