MySQL View the maximum number of connections and modify the maximum number of connections 1. Check the maximum number of connections show variables like '%max_connections%'; 2. Modify the maximum number of connections set GLOBAL max_connections = 200; The following article mainly introduces the modification of the maximum number of MySQL connections. We all know that the default value of the maximum number of MySQL connections is 100. This value is far from enough for applications with many concurrent database connections. When the connection request is greater than the default number of connections, an error will occur that the database cannot be connected, so we need to increase it appropriately. Too many MySQL database connections cause system errors and the system cannot connect to the database. The key lies in two data: 1. The maximum number of connections allowed by the database system 2. The current number of database connection threads: We will talk about how to check max_connections and max_connections below. If Because creating and destroying database connections will consume system resources. In order to avoid opening too many connection threads at the same time, current programming generally uses the so-called database connection pool technology. However, database connection pool technology cannot prevent program errors from causing exhaustion of connection resources. This situation usually occurs when the program fails to release the database connection resources in time or other reasons cause the database connection resources to not be released. A simple way to check for similar errors is to constantly monitor the changes in threads_connected when refreshing the page. If max_connections is large enough and the threads_connected value continues to increase until it reaches max_connections, then you should check your program. Of course, if the database connection pool technology is used, threads_connected will no longer grow when it reaches the maximum number of connection threads in the database connection pool. Check show variables like "max_connections"; The results are as follows: +-----------------+-------+ | Variable_name | Value | +-----------------+-------+ | max_connections | 100 | +-----------------+-------+ View threads_connected show status like 'Thread_%'; The results are as follows: +-------------------+------+ | Variable_name | Value | +-------------------+------+ | Threads_cached | 0 | | Threads_connected | 1 | | Threads_created | 1 | | Threads_running | 1 | +-------------------+------+ Setting To set it, find the [mysqld] max_connections=1000 After the modification is complete, restart MySQL. Of course, you should look at max_connections to make sure it is set correctly. Notice:
Other things to note: When programming, when you use MySQL statements to call the database, a temporary variable will be created before each statement is executed to open the database. Therefore, when you use MySQL statements, remember to close the MySQL temporary variable after each call to MySQL. In addition, for documents with large traffic, you can consider writing them directly into text. Based on the predicted traffic, first define the file names if there are 100 files. When necessary, analyze the data in all text files and then import them into the database. Summarize The above is the full content of this article. I hope that the content of this article will have certain reference learning value for your study or work. Thank you for your support of 123WORDPRESS.COM. If you want to learn more about this, please check out the following links You may also be interested in:
|
<<: CentOS7 upgrade kernel kernel5.0 version
>>: Problems and solutions of using jsx syntax in React-vscode
1. Overview The image in Docker is designed in la...
MySQL DATE_ADD(date,INTERVAL expr type) and ADDDA...
In general applications, we use timestamp, dateti...
<body> <div id="root"> <...
Table of contents Introduction effect principle f...
Table of contents Preface 1. ss command 2. Overal...
Table of contents Where are the logs stored? View...
Official website explanation: When a component is...
Table of contents 1. Problem Description 2. Probl...
introduction It is okay to add or not add a semic...
For many people who are new to HTML, table <ta...
Table of contents vue custom directive Global Dir...
Simple example of HTML checkbox and radio style b...
Copy code The code is as follows: <html xmlns=...
Preface PC Server has developed to this day and h...