Detailed explanation of how to view the current number of MySQL connections

Detailed explanation of how to view the current number of MySQL connections

1. View the detailed information of all current connections:

./mysqladmin -uadmin -p -h10.140.1.1 processlist2. View only the current number of connections (Threads is the number of connections):

./mysqladmin -uadmin -p -h10.140.1.1 status

, View detailed information 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. Only view the current number of 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.3893, modify the maximum number of mysql connections:

Open my.ini and modify max_connections=100 (the default is 100).

Today, a MySQL server suddenly had a surge in connections, and all waiting processes were locked... Because of improper problem solving, I was scolded...OTL

Summary: In the future, we should quickly locate errors and arrange solutions

After logging in to the MySQL client, you can also use the status command to obtain the number of thread connections and the ID of the current connection.

Or use

show full processlist

Take a look at all the connection processes, pay attention to the process waiting time and whether the status is locked

If there are too many processes, print out the processes and then check

mysql -e 'show full processlist;' > . This is usually because the current execution is stuck, causing the subsequent processes to be queued.

In addition, the method to modify the maximum number of MySQL connections:

Edit MySQL (best combination with PHP) configuration file

my.cnf or my.ini

Add the following to the [MySQL (best combination with PHP)] configuration section:

max_connections = 1000 Save and restart the MySQL (best combination with PHP) service.

Then use the command: Where is the best place for abortion surgery in Wuxi? http://www.120csjlyy.com/

MySQL (best combination with PHP) admin -uroot -p variables

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

| max_connections | 1000 | View the number of MySQL connections and the number of MySQL connections for the current user

First enter the mysql prompt as an administrator.

#mysql -uroot -pxxxx

mysql> show processlist; can display the first 100 connection information, show full processlist; can display all. By the way, if you log in with a normal account, only this user's will be displayed. Note the semicolon after the command.

If we want to view this server settings.

#vi /etc/my.cnfset-variable=max_user_connections=30 This is the number of connections for a single userset-variable=max_connections=800

This is the global limit on the number of connections.

Summarize

The above is a detailed explanation of how to view the current number of MySQL connections introduced by the editor. I hope it will be helpful to everyone. If you have any questions, please leave me a message and the editor will reply to you in time. I would also like to thank everyone for their support of the 123WORDPRESS.COM website!
If you find this article helpful, please feel free to reprint it and please indicate the source. Thank you!

You may also be interested in:
  • Python connects to the database MySQL decompressed version installation configuration and encountered problems
  • Mysql view the maximum number of connections and modify the maximum number of connections
  • Summary of tips for setting the maximum number of connections in MySQL
  • Solution to the problem that the number of MySQL connections is limited to 214 in CentOS 7
  • How to set the number of mysql connections (Too many connections)
  • Perfect solution to the problem that MySQL cannot connect to the database through localhost
  • How to use Java Web to connect to MySQL database
  • Python 3.x database connection example (pymysql method)
  • PHP mysql operation mysql_connect connection database instance detailed explanation
  • Summarize two ways to modify the maximum number of connections in MySQL
  • How to set and get the number of Mysql connections

<<:  When backing up files in Centos7, add the backup date to the backup file

>>:  An article to understand operators in ECMAScript

Recommend

Database query optimization: subquery optimization

1. Case Take all employees who are not the head o...

Detailed explanation of the use and precautions of crontab under Linux

Crontab is a command used to set up periodic exec...

Use of environment variables in Docker and solutions to common problems

Preface Docker can configure environment variable...

How to Learn Algorithmic Complexity with JavaScript

Table of contents Overview What is Big O notation...

Docker MQTT installation and use tutorial

Introduction to MQTT MQTT (Message Queuing Teleme...

CentOS 8 is now available

CentOS 8 is now available! CentOS 8 and RedHat En...

Detailed explanation of CSS multiple three-column adaptive layout implementation

Preface In order to follow the conventional WEB l...

Summary of how to use the MySQL authorization command grant

How to use the MySQL authorization command grant:...

Use Nginx to build a streaming media server to realize live broadcast function

Written in front In recent years, the live stream...

Native JS to implement sharing sidebar

This article shares a sharing sidebar implemented...

Analyze the usage and principles of Vue's provide and inject

First, let's talk about why we use provide/in...

3 Tips You Must Know When Learning JavaScript

Table of contents 1. The magical extension operat...