MySQL database management method, device, electronic device and storage medium

By constructing a running status topology diagram of the MySQL database and obtaining and processing abnormal SQL statements, the system delays and lags caused by database performance issues are resolved, and rapid problem location and stable system operation are achieved.

CN114138914BActive Publication Date: 2025-09-26INDUSTRIAL AND COMMERCIAL BANK OF CHINA
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202111502284.0
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2021-12-09
Publication Date
2025-09-26
Estimated Expiration
2041-12-09

AI Technical Summary

Technical Problem

In the existing technology, database performance problems cause slow system response or unavailability, and operation and maintenance personnel have delays and lags in finding and solving problems, which lacks accuracy.

Method used

By obtaining the SQL statements and execution status in the MySQL database, a running status topology map is constructed. The topology map is used to identify and process SQL statements in abnormal states, including monitoring the server's memory and CPU usage, number of threads, and execution status of SQL statements, and terminating the execution of abnormal SQL statements.

Benefits of technology

This enables database operation and maintenance personnel to understand the operating status in a timely manner, quickly locate and solve problems, avoid system unavailability or slow execution, and ensure stable system operation.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN114138914B_ABST
    Figure CN114138914B_ABST
Patent Text Reader

Abstract

The present disclosure provides a MySQL database management method, device, electronic device, storage medium, and program product that can be used in the financial field and other fields. The MySQL database management method includes: when the status of the server where the MySQL database is located meets a preset condition, obtaining SQL statements and the execution status of the SQL statements in the MySQL database, constructing an operation status topology map of the MySQL database based on the SQL statements and the execution status of the SQL statements, and using the operation status topology map of the MySQL database to determine and process all SQL statements in the MySQL database that are in an abnormal state. The MySQL database management method provided by the present disclosure can help database operation and maintenance personnel to promptly understand the database operation status, facilitate operation and maintenance personnel to quickly locate and solve problems, avoid the situation where the database system is unavailable or the database system executes slowly due to inefficient SQL statement execution, and effectively ensure the stable operation of the system.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present disclosure relates to the technical field of relational databases, and in particular to a MySQL database management method, device, electronic device, storage medium, and program product. Background Art

[0002] When a production application system is temporarily unavailable or unavailable for a long time, a large part of the reason is related to database performance. Due to the large number of users accessing the system concurrently and the uncertainty of accessing the system, performance problems may occur in the database at a certain moment, resulting in slow response of the entire application system or unavailability of the application system. When a database performance problem occurs, the monitoring system usually issues an alarm first, and the operation and maintenance personnel process the database after receiving the alarm. At this time, it may be found that a large number of SQL statements are running. The database administrator needs to locate each SQL statement and then check and kill the problematic SQL statements. This processing method has a delay in solving the problem. Or when the database administrator queries the database status, the database performance has recovered. The database administrator needs to query the corresponding log of the MySQL database to locate the problem. This method has a lag in solving the problem. In summary, in the existing technology, the alarm information for abnormal conditions in the system is too broad and lacks accuracy for operation and maintenance personnel to find and solve problems. Summary of the Invention

[0003] In view of the above problems, the present disclosure provides a MySQL database management method, device, electronic device, storage medium and program product.

[0004] According to a first aspect of the present disclosure, a MySQL database management method is provided, the method comprising:

[0005] When the status of the server where the MySQL database is located meets the preset conditions, the SQL statement in the MySQL database and the execution status of the SQL statement are obtained;

[0006] Based on the above SQL statements and the execution status of the above SQL statements, construct an operation status topology diagram of the above MySQL database;

[0007] Utilize the operation status topology diagram of the above MySQL database to determine and process all SQL statements in the above MySQL database that are in abnormal state.

[0008] In one embodiment of the present disclosure, when the status of the server where the MySQL database is located meets a preset condition, before obtaining the execution status of the SQL statement in the MySQL database, the method further includes:

[0009] Periodically obtain the memory usage, CPU usage, and MySQL database process of the above server;

[0010] Determine whether the memory usage, CPU usage, and process of the MySQL database of the server meet preset conditions.

[0011] In one embodiment of the present disclosure, the above-mentioned preset conditions are:

[0012] A change value of at least one of the memory usage, CPU usage of the server, and the process of the MySQL database exceeds a corresponding preset threshold.

[0013] In one embodiment of the present disclosure, the execution status of the above-mentioned SQL statements includes the execution thread number of each of the above-mentioned SQL statements.

[0014] In one embodiment of the present disclosure, before determining and processing all abnormal SQL statements in the MySQL database using the operation status topology diagram of the MySQL database, the method further includes:

[0015] Obtain the total number of threads currently executing in the MySQL database through the running status topology diagram of the MySQL database;

[0016] When the total number of threads exceeds a preset first threshold, it is determined that the MySQL database is in an abnormal state;

[0017] When the MySQL database is in an abnormal state, all SQL statements in the MySQL database that are in an abnormal state are determined and processed.

[0018] In one embodiment of the present disclosure, the above-mentioned determination and processing of all SQL statements in the above-mentioned MySQL database that are in an abnormal state specifically includes:

[0019] When a currently executed SQL statement is in a locked state, it is determined that the currently executed SQL statement is in an abnormal state;

[0020] When the execution time of one of the currently executed SQL statements exceeds a preset second threshold, it is determined that the currently executed SQL statement is in an abnormal state;

[0021] Terminates the execution of all SQL statements that are in an abnormal state.

[0022] A second aspect of the present disclosure provides a MySQL database management device, the device comprising:

[0023] An acquisition module is used to acquire the SQL statements in the MySQL database and the execution status of the SQL statements when the status of the server where the MySQL database is located meets a preset condition;

[0024] A construction module is used to construct an operation status topology diagram of the MySQL database based on the SQL statement and the execution status of the SQL statement;

[0025] The processing module is used to use the operation status topology diagram of the above-mentioned MySQL database to determine and process all SQL statements in the above-mentioned MySQL database that are in an abnormal state.

[0026] A third aspect of the present disclosure provides an electronic device, including:

[0027] one or more processors;

[0028] a memory for storing one or more programs,

[0029] When the one or more programs are executed by the one or more processors, the one or more processors execute the MySQL database management method.

[0030] A fourth aspect of the present disclosure further provides a computer-readable storage medium having executable instructions stored thereon, which, when executed by a processor, causes the processor to execute the above-mentioned MySQL database management method.

[0031] A fifth aspect of the present disclosure further provides a computer program product, comprising a computer program, which implements the above-mentioned MySQL database management method when executed by a processor.

[0032] The MySQL database management method disclosed herein includes: when the status of the server hosting the MySQL database satisfies a preset condition, obtaining SQL statements and the execution status of the SQL statements in the MySQL database; constructing a topological map of the MySQL database's operational status based on the SQL statements and the execution status of the SQL statements; and using the topological map of the MySQL database's operational status to identify and process all SQL statements in the MySQL database that are in an abnormal state. This method can help database operation and maintenance personnel promptly understand the database's operational status, facilitate rapid problem location and resolution, avoid system unavailability or slow execution of the database system due to inefficient SQL statement execution, and effectively ensure stable system operation. BRIEF DESCRIPTION OF THE DRAWINGS

[0033] In order to more clearly illustrate the embodiments of the present disclosure or the technical solutions in the prior art, the following briefly introduces the drawings required for use in the embodiments or the description of the prior art. Obviously, the drawings described below are only some embodiments of the present disclosure. For those skilled in the art, other drawings can be obtained based on these drawings without creative work.

[0034] Figure 1 The following schematically illustrates an application scenario diagram of a MySQL database management method according to an embodiment of the present disclosure;

[0035] Figure 2 The following schematically illustrates a flow chart of a MySQL database management method provided by an embodiment of the present disclosure;

[0036] Figure 3 The following schematically illustrates a flow chart of another MySQL database management method provided by an embodiment of the present disclosure;

[0037] Figure 4 The following schematically illustrates a flow chart of another MySQL database management method provided by an embodiment of the present disclosure;

[0038] Figure 5 The following schematically illustrates a flow chart of a method for determining and processing all SQL statements in an abnormal state in a MySQL database provided by an embodiment of the present disclosure;

[0039] Figure 6 The following schematically shows a structural block diagram of a MySQL database management device provided by an embodiment of the present disclosure;

[0040] Figure 7 The following schematically shows a structural block diagram of another MySQL database management device provided by an embodiment of the present disclosure;

[0041] Figure 8 The following schematically shows a structural block diagram of another MySQL database management device provided by an embodiment of the present disclosure;

[0042] Figure 9 A block diagram schematically illustrates a structure of a processing module of a MySQL database management device provided by an embodiment of the present disclosure; and

[0043] Figure 10 A block diagram of an electronic device suitable for implementing a MySQL database management method according to an embodiment of the present disclosure is schematically shown. DETAILED DESCRIPTION

[0044] Hereinafter, embodiments of the present disclosure will be described with reference to the accompanying drawings. However, it should be understood that these descriptions are merely exemplary and are not intended to limit the scope of the present disclosure. In the detailed description below, for ease of explanation, many specific details are set forth to provide a comprehensive understanding of the embodiments of the present disclosure. However, it is apparent that one or more embodiments may also be implemented without these specific details. In addition, in the following description, descriptions of well-known structures and technologies are omitted to avoid unnecessary confusion of the concepts of the present disclosure.

[0045] The terms used herein are only for describing specific embodiments and are not intended to limit the present disclosure. The terms "comprise," "include," etc. used herein indicate the presence of the features, steps, operations, and / or components, but do not exclude the presence or addition of one or more other features, steps, operations, or components.

[0046] All terms used herein (including technical and scientific terms) have the meanings commonly understood by those skilled in the art unless otherwise defined. It should be noted that the terms used herein should be interpreted as having a meaning consistent with the context of this specification and should not be interpreted in an idealized or overly rigid manner.

[0047] When expressions such as “at least one of A, B, and C, etc.” are used, they should generally be interpreted in accordance with the meaning commonly understood by those skilled in the art (e.g., “a system having at least one of A, B, and C” should include but is not limited to systems having A alone, B alone, C alone, A and B, A and C, B and C, and / or A, B, and C, etc.). When expressions such as “at least one of A, B, or C, etc.” are used, they should generally be interpreted in accordance with the meaning commonly understood by those skilled in the art (e.g., “a system having at least one of A, B, or C” should include but is not limited to systems having A alone, B alone, C alone, A and B, A and C, B and C, and / or A, B, and C, etc.). Those skilled in the art should also understand that any transitional conjunctions and / or phrases that essentially represent two or more optional items, whether in the specification, claims, or drawings, should be understood to provide the possibility of including one, either, or both of these items. For example, the phrase "A or B" should be understood to include the possibilities of "A" or "B", or "A and B".

[0048] Some block diagrams and / or flow charts are shown in the accompanying drawings. It should be understood that some blocks in the block diagrams and / or flow charts or their combinations can be implemented by computer program instructions. These computer program instructions can be provided to a processor of a general-purpose computer, a special-purpose computer or other programmable data processing device, so that these instructions can create a device for implementing the functions / operations described in these block diagrams and / or flow charts when executed by the processor. The technology of the present disclosure can be implemented in the form of hardware and / or software (including firmware, microcode, etc.). In addition, the technology of the present disclosure can take the form of a computer program product on a computer-readable medium storing instructions, which can be used by an instruction execution system or in combination with an instruction execution system. In the context of the present disclosure, a computer-readable medium can be any medium that can contain, store, transmit, propagate or transmit instructions. For example, a computer-readable medium can include, but is not limited to, an electrical, magnetic, optical, electromagnetic, infrared or semiconductor system, device, component or propagation medium. Specific examples of computer-readable media include: magnetic storage devices, such as magnetic tape or hard disks (HDDs); optical storage devices, such as compact disks (CD-ROMs); memories, such as random access memory (RAM) or flash memory; and / or wired / wireless communication links.

[0049] The present disclosure provides a MySQL database management method, apparatus, electronic device, storage medium, and program product. The following is an illustrative description with reference to the accompanying drawings. It should be noted that the sequence numbers of the various operations in the following method are merely used to indicate the operation for ease of description and should not be construed as indicating the order in which the operations must be performed. Unless explicitly stated, the method does not need to be performed in the exact order shown.

[0050] The present disclosure provides a MySQL database management method, comprising: when the status of a server hosting the MySQL database satisfies a preset condition, obtaining SQL statements and the execution status of the SQL statements in the MySQL database; constructing an operational status topology map of the MySQL database based on the SQL statements and the execution status of the SQL statements; and using the operational status topology map of the MySQL database to identify and process all SQL statements in the MySQL database that are in an abnormal state. This method can help database operation and maintenance personnel promptly understand the database operational status, facilitate rapid problem location and resolution, avoid system unavailability or slow execution of the database system due to inefficient SQL statement execution, and effectively ensure stable system operation.

[0051] It should be noted that the MySQL database management method and device provided in the present disclosure can be used in the financial field, and can also be used in any field other than the financial field. The present disclosure does not limit the application field of the provided MySQL database management method and device.

[0052] Figure 1 The following schematically shows an application scenario diagram of a MySQL database management method according to an embodiment of the present disclosure. Figure 1 As shown, the application scenario diagram according to this embodiment may include terminal devices 101, 102, 103, a network 104, and a server / server cluster 105. The network 104 is used as a medium for providing a communication link between the terminal devices 101, 102, 103 and the server / server cluster 105. The network 104 may include various connection types, such as wired or wireless communication links or optical fiber cables.

[0053] Users can use terminal devices 101, 102, and 103 to interact with the server / server cluster 105 via the network 104 to receive or send messages, etc. Various client applications can be installed on the terminal devices 101, 102, and 103, such as shopping applications, web browser applications, search applications, instant messaging tools, email clients, social platform software, etc. (only as examples).

[0054] The terminal devices 101 , 102 , and 103 can interact with the server / server cluster 105 through various client applications to send various requests to the server / server cluster 105 or receive results returned by the server / server cluster 105 .

[0055] The terminal devices 101 , 102 , and 103 may be various electronic devices, including but not limited to smart phones, tablet computers, laptop computers, and desktop computers.

[0056] The server / server cluster 105 can be a server that provides various services, such as a background management server (for example only) that supports websites browsed by users using terminal devices 101, 102, and 103. The background management server can analyze and process received data such as user requests, and feed back the processing results (such as web pages, information, or data obtained or generated according to user requests) to the terminal device.

[0057] It should be noted that the MySQL database management method provided in the embodiment of the present disclosure can generally be executed by the server / server cluster 105. Accordingly, the MySQL database management device provided in the embodiment of the present disclosure can generally be set in the server / server cluster 105. The MySQL database management method provided in the embodiment of the present disclosure can also be executed by a server or server cluster that is different from the server / server cluster 105 and can communicate with the terminal devices 101, 102, 103 and / or the server / server cluster 105. Accordingly, the MySQL database management device provided in the embodiment of the present disclosure can also be set in a server or server cluster that is different from the server / server cluster 105 and can communicate with the terminal devices 101, 102, 103 and / or the server / server cluster 105.

[0058] It should be understood that Figure 1 The numbers of terminal devices, networks, and servers / server clusters shown are merely illustrative. Any number of terminal devices, networks, and servers / server clusters may be used as needed.

[0059] The following will be based on Figure 1 The scene described by Figures 2 to 5 A MySQL database management method according to an embodiment of the present disclosure is described in detail. This will facilitate a clearer understanding of the technical solution of the present disclosure by those skilled in the art. It should be understood that the following description is merely exemplary to help those skilled in the art understand the solution of the present disclosure and is not intended to limit the scope of protection of the present disclosure.

[0060] Figure 2 The following schematically shows a flow chart of a MySQL database management method provided by an embodiment of the present disclosure. Figure 2 As shown, in one embodiment of the present disclosure, the method includes operations S210 to S230.

[0061] In operation S210, when the status of the server where the MySQL database is located meets a preset condition, the SQL statements in the MySQL database and the execution status of the SQL statements are obtained.

[0062] In this embodiment, when the status of the server where the MySQL database is located meets the preset conditions, the show full processlist statement can be executed in the MySQL database to obtain the execution status of the SQL statement in the MySQL database. The execution status of the SQL statement includes the execution thread number of each of the above SQL statements, as well as: user, host address, connected host library, command, execution time, status, etc.

[0063] It should be understood that the method for obtaining the execution status of SQL statements in a MySQL database in this embodiment is merely exemplary, intended to help those skilled in the art understand the technical solution of this disclosure, and is not intended to limit the scope of protection of this disclosure. The method for obtaining the execution status of SQL statements in a MySQL database can be selected based on actual needs and is not limited here.

[0064] In operation S220, based on the SQL statements and the execution status of the SQL statements, a running status topology diagram of the MySQL database is constructed.

[0065] In operation S230, all SQL statements in the MySQL database that are in an abnormal state are determined and processed using the operation status topology diagram of the MySQL database.

[0066] In this embodiment, the status of the server where the MySQL database is located is monitored in real time. When the status of the server where the MySQL database is located meets the preset conditions, the SQL statements in the MySQL database and the execution status of the SQL statements are obtained. Then, based on the SQL statements in the MySQL database and the execution status of the SQL statements, a topology diagram reflecting the running status of the MySQL database is constructed. This method can not only help the operation and maintenance personnel of the MySQL database to understand the running status of the database in a timely manner, but also quickly locate and solve the problem when the MySQL database is in an abnormal state, avoiding the situation where the MySQL database system is unavailable or the database system executes slowly due to the low execution efficiency of the SQL statements, and can effectively ensure the stable operation of the system.

[0067] Figure 3 The following schematically shows a flow chart of another MySQL database management method provided by an embodiment of the present disclosure. Figure 3 As shown, in one embodiment of the present disclosure, before the above operation S210, the above method further includes operations S310 to S320.

[0068] In operation S310 , the memory usage, CPU usage, and MySQL database process of the server are periodically obtained.

[0069] In operation S320 , it is determined whether the memory usage, CPU usage, and the process of the MySQL database of the server meet preset conditions.

[0070] In this embodiment, the preset condition is that a change value of at least one of the memory usage, CPU usage of the server, and the process of the MySQL database exceeds a corresponding preset threshold.

[0071] In this embodiment, the status of the server where the MySQL database resides is monitored in real time. The server's memory usage, CPU usage, and MySQL database processes are periodically obtained. For example, the server's memory usage, CPU usage, and MySQL database processes are obtained every 5 seconds. A determination is then made as to whether at least one of these changes exceeds a corresponding preset threshold. Real-time monitoring of the server where the MySQL database resides allows for timely acquisition of the MySQL database's status, thereby promptly updating the topology map and ensuring that the topology map displays the latest operational status of the MySQL database. This facilitates database operations and maintenance personnel in promptly identifying and addressing database anomalies, thereby ensuring stable database operation.

[0072] It should be understood that the example of the period for obtaining the status of the server where the MySQL database resides in this embodiment is merely illustrative, to help those skilled in the art understand the technical solution of this disclosure, and is not intended to limit the scope of protection of this disclosure. The period for obtaining the status of the server where the MySQL database resides can be selected according to actual needs and is not limited here.

[0073] Figure 4 The following schematically shows a flow chart of another MySQL database management method provided by an embodiment of the present disclosure. Figure 4 As shown, in one embodiment of the present disclosure, before the above operation S230, the above method further includes operations S410 to S430.

[0074] In operation S410, the total number of threads currently executed in the MySQL database is obtained through the operation status topology diagram of the MySQL database.

[0075] In operation S420 , when the total number of threads exceeds a preset first threshold, it is determined that the MySQL database is in an abnormal state.

[0076] In operation S430, when the MySQL database is in an abnormal state, all SQL statements in the MySQL database that are in an abnormal state are determined and processed.

[0077] In this embodiment, by analyzing the topological diagram of the running status of the MySQL database, the total number of threads currently executed in the MySQL database can be obtained. Because the number of threads in the database is set according to the baseline, when the number of threads simultaneously executed in the database exceeds the threshold, the database may be slow to execute and may crash. Therefore, when the total number of threads currently executed in the above-mentioned MySQL database exceeds the preset first threshold, it indicates that the MySQL database is in an abnormal state. When the MySQL database is in an abnormal state, it is necessary to analyze and process the SQL statements in the MySQL database. Based on the constructed MySQL database running status topological diagram, the total number of threads currently executed in the MySQL database can be quickly obtained, the status of the MySQL database can be determined in a timely manner, and countermeasures can be taken in a timely manner according to the status of the MySQL database to ensure the stable operation of the MySQL database.

[0078] Figure 5 The following schematically shows a flow chart of a method for determining and processing all abnormal SQL statements in a MySQL database provided by an embodiment of the present disclosure. Figure 5 As shown, in one embodiment of the present disclosure, the method includes operations S510 to S530.

[0079] In operation S510 , when there is a currently executed SQL statement in a locked state, it is determined that the currently executed SQL statement is in an abnormal state.

[0080] In operation S520 , when there is a SQL statement currently being executed whose execution time exceeds a preset second threshold, it is determined that the SQL statement currently being executed is in an abnormal state.

[0081] In operation S530 , the execution of all SQL statements in abnormal states is terminated.

[0082] In this embodiment, when the MySQL database is in an abnormal state, it is necessary to determine which SQL statements are causing the abnormal state. Therefore, it is necessary to analyze the SQL statements currently being executed in the MySQL database. For example, the status of the SQL statements is judged. If the status of a currently executed SQL statement is a locked state, the SQL statement is executed slowly, which will affect the performance of the MySQL database. Therefore, it is determined that the SQL statement is in an abnormal state and needs to be processed. Alternatively, if the execution time of a currently executed SQL statement exceeds a preset second threshold, it is determined that the SQL statement is executed slowly, the SQL statement is in an abnormal state, and needs to be processed. When the MySQL database is in an abnormal state, by analyzing the SQL statements currently being executed in the MySQL database, the SQL statements in the abnormal state can be quickly located, and the operation of all SQL statements in the abnormal state can be terminated. This can promptly resolve the abnormality of the MySQL database and effectively ensure the stable operation of the system.

[0083] It should be understood that the method for handling SQL statements in an abnormal state in this embodiment is merely exemplary, to help those skilled in the art understand the technical solution of this disclosure, and is not intended to limit the scope of protection of this disclosure. The method for handling SQL statements in an abnormal state can be selected according to actual needs and is not limited here.

[0084] Based on the above-mentioned MySQL database management method, the present disclosure also provides a MySQL database management device. Figure 6-Figure 9 The device is described in detail.

[0085] Figure 6 The following schematically shows a structural block diagram of a MySQL database management device provided by an embodiment of the present disclosure.

[0086] like Figure 6 As shown, in one embodiment of the present disclosure, the MySQL database management device 600 includes: an acquisition module 610 , a construction module 620 and a processing module 630 .

[0087] The acquisition module 610 is used to acquire the SQL statements in the MySQL database and the execution status of the SQL statements when the status of the server where the MySQL database is located meets the preset conditions. In one embodiment, the acquisition module 610 can be used to perform the operation S210 described above, which will not be repeated here.

[0088] The construction module 620 is used to construct the operation status topology diagram of the MySQL database based on the SQL statement and the execution status of the SQL statement. In one embodiment, the construction module 620 can be used to perform the operation S220 described above, which will not be repeated here.

[0089] The processing module 630 is used to determine and process all abnormal SQL statements in the MySQL database using the operation status topology diagram of the MySQL database. In one embodiment, the processing module 630 can be used to perform the operation S230 described above, which will not be repeated here.

[0090] Figure 7 The structural block diagram of another MySQL database management device provided by an embodiment of the present disclosure is schematically shown.

[0091] like Figure 7 As shown, in one embodiment of the present disclosure, the apparatus 600 further includes: a second acquisition module 710 and a judgment module 720 .

[0092] The second acquisition module 710 is used to periodically acquire the memory usage, CPU usage and MySQL database process of the server. In one embodiment, the second acquisition module 710 can be used to perform the operation S310 described above, which will not be repeated here.

[0093] The judgment module 720 is used to judge whether the memory usage, CPU usage and process of the MySQL database of the server meet the preset conditions. In one embodiment, the judgment module 720 can be used to perform the operation S320 described above, which will not be repeated here.

[0094] Figure 8 The structural block diagram of another MySQL database management device provided by an embodiment of the present disclosure is schematically shown.

[0095] like Figure 8 As shown, in one embodiment of the present disclosure, the apparatus 600 further includes: a third acquisition module 810 , a second judgment module 820 and a third judgment module 830 .

[0096] The third acquisition module 810 is used to obtain the total number of threads currently executed in the MySQL database through the operation status topology diagram of the MySQL database. In one embodiment, the third acquisition module 810 can be used to perform the operation S410 described above, which will not be repeated here.

[0097] The second judgment module 820 is configured to determine that the MySQL database is in an abnormal state when the total number of threads exceeds a preset first threshold. In one embodiment, the second judgment module 820 may be configured to execute the operation S420 described above, which will not be described in detail herein.

[0098] The third judgment module 830 is used to determine and process all abnormal SQL statements in the MySQL database when the MySQL database is in an abnormal state. In one embodiment, the third judgment module 830 can be used to perform the operation S430 described above, which will not be repeated here.

[0099] Figure 9 The following schematically shows a structural block diagram of a processing module of a MySQL database management device provided by an embodiment of the present disclosure.

[0100] like Figure 9 As shown, in one embodiment of the present disclosure, the processing module 630 includes: a fourth judgment module 910 , a fifth judgment module 920 and a termination module 930 .

[0101] The fourth judgment module 910 is configured to determine that the currently executed SQL statement is in an abnormal state when a currently executed SQL statement is in a locked state. In one embodiment, the fourth judgment module 910 may be configured to execute the operation S510 described above, which will not be described in detail herein.

[0102] The fifth judgment module 920 is configured to determine that the currently executed SQL statement is in an abnormal state when the execution time of the currently executed SQL statement exceeds a preset second threshold. In one embodiment, the fifth judgment module 920 can be configured to perform operation S520 described above, which will not be repeated here.

[0103] The termination module 930 is used to terminate the execution of all SQL statements in an abnormal state. In one embodiment, the termination module 930 can be used to perform the operation S530 described above, which will not be repeated here.

[0104] It should be noted that the implementation methods, technical problems solved, functions implemented, and technical effects achieved of each module / unit / sub-unit in the device part embodiment are the same or similar to the implementation methods, technical problems solved, functions implemented, and technical effects achieved of each corresponding step in the method part embodiment, and will not be repeated here.

[0105] According to the modules, submodules, units, and subunits of the embodiments of the present invention, any multiple or at least part of the functions of any multiple thereof can be implemented in one module. According to the modules, submodules, units, and subunits of the embodiments of the present invention, any one or more thereof can be split into multiple modules for implementation. According to the modules, submodules, units, and subunits of the embodiments of the present invention, any one or more thereof can be at least partially implemented as a hardware circuit, such as a field programmable gate array (FPGA), a programmable logic array (PLA), a system on a chip, a system on a substrate, a system on a package, an application specific integrated circuit (ASIC), or can be implemented by hardware or firmware of any other reasonable way of integrating or packaging the circuit, or implemented in any one of the three implementation modes of software, hardware, and firmware or in an appropriate combination of any of them. Alternatively, according to the modules, submodules, units, and subunits of the embodiments of the present invention, one or more thereof can be at least partially implemented as a computer program module, which can perform the corresponding function when the computer program module is run.

[0106] For example, any multiple of the acquisition module 610, the construction module 620, and the processing module 630 can be combined into one module for implementation, or any one of the modules can be split into multiple modules. Alternatively, at least part of the functions of one or more of these modules can be combined with at least part of the functions of other modules and implemented in one module. According to an embodiment of the present disclosure, at least one of the acquisition module 610, the construction module 620, and the processing module 630 can be at least partially implemented as a hardware circuit, such as a field programmable gate array (FPGA), a programmable logic array (PLA), a system on a chip, a system on a substrate, a system on a package, an application specific integrated circuit (ASIC), or can be implemented by hardware or firmware such as any other reasonable way of integrating or packaging the circuit, or implemented in any one of the three implementation modes of software, hardware, and firmware, or in an appropriate combination of any of them. Alternatively, at least one of the acquisition module 610, the construction module 620, and the processing module 630 can be at least partially implemented as a computer program module, which can perform the corresponding function when the computer program module is run.

[0107] Figure 10 A block diagram of an electronic device suitable for implementing a MySQL database management method according to an embodiment of the present disclosure is schematically shown.

[0108] like Figure 10As shown, the electronic device 1000 according to an embodiment of the present disclosure includes a processor 1001, which can perform various appropriate actions and processes according to a program stored in a read-only memory (ROM) 1002 or a program loaded from a storage part 1008 into a random access memory (RAM) 1003. The processor 1001 may, for example, include a general-purpose microprocessor (e.g., a CPU), an instruction set processor and / or a related chipset and / or a dedicated microprocessor (e.g., an application-specific integrated circuit (ASIC)), etc. The processor 1001 may also include an onboard memory for caching purposes. The processor 1001 may include a single processing unit or multiple processing units for performing different actions of the method flow according to an embodiment of the present disclosure.

[0109] Various programs and data required for the operation of the electronic device 1000 are stored in the RAM 1003. The processor 1001, the ROM 1002, and the RAM 1003 are connected to each other via a bus 1004. The processor 1001 performs various operations of the method flow according to the embodiment of the present disclosure by executing the programs in the ROM 1002 and / or the RAM 1003. It should be noted that the programs may also be stored in one or more memories other than the ROM 1002 and the RAM 1003. The processor 1001 may also perform various operations of the method flow according to the embodiment of the present disclosure by executing the programs stored in the one or more memories.

[0110] According to an embodiment of the present disclosure, electronic device 1000 may further include an input / output (I / O) interface 1005, which is also connected to bus 1004. Electronic device 1000 may further include one or more of the following components connected to I / O interface 1005: an input section 1006 including a keyboard, a mouse, etc.; an output section 1007 including devices such as a cathode ray tube (CRT), a liquid crystal display (LCD), and speakers; a storage section 1008 including a hard disk; and a communication section 1009 including a network interface card such as a LAN card or a modem. Communication section 1009 performs communication processing via a network such as the Internet. A drive 1010 is also connected to I / O interface 1005 as needed. Removable media 1011, such as a magnetic disk, an optical disk, a magneto-optical disk, a semiconductor memory, etc., is installed in drive 1010 as needed, so that computer programs read therefrom can be installed into storage section 1008 as needed.

[0111] The present disclosure also provides a computer-readable storage medium storing a computer program that includes a MySQL database management method as described above. The computer-readable storage medium may be included in the apparatus / device described in the above embodiments, or it may exist independently and not be incorporated into the apparatus / device. The computer-readable storage medium carries one or more programs that, when executed, implement the method according to the embodiments of the present disclosure.

[0112] According to an embodiment of the present disclosure, a computer-readable medium may be a computer-readable signal medium or a computer-readable storage medium or any combination thereof. A computer-readable storage medium may be, for example, but not limited to, an electrical, magnetic, optical, electromagnetic, infrared, or semiconductor system, device, or component, or any combination thereof. More specific examples of computer-readable storage media may include, but are not limited to, an electrical connection with one or more wires, a portable computer disk, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disk read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination thereof. In the present disclosure, a computer-readable storage medium may be any tangible medium containing or storing a program that can be used by or in combination with an instruction execution system, device, or device. For example, according to an embodiment of the present disclosure, a computer-readable storage medium may include the ROM 1002 and / or RAM 1003 described above and / or one or more memories other than ROM 1002 and RAM 1003.

[0113] The embodiments of the present disclosure also include a computer program product, which includes a computer program containing program code for executing the method shown in the flowchart. When the computer program product is executed in a computer system, the program code is used to enable the computer system to implement a MySQL database management method provided by the embodiments of the present disclosure.

[0114] The computer program executes the above functions defined in the system / device of the embodiment of the present disclosure when the processor 1001 executes the computer program. According to the embodiment of the present disclosure, the system, device, module, unit, etc. described above can be implemented by a computer program module.

[0115] In one embodiment, the computer program may be stored on a tangible storage medium such as an optical storage device or a magnetic storage device. In another embodiment, the computer program may be transmitted and distributed in the form of a signal on a network medium, downloaded and installed via the communication portion 1009, and / or installed from the removable medium 1011. The program code contained in the computer program may be transmitted using any appropriate network medium, including but not limited to wireless, wired, or any suitable combination thereof.

[0116] In such an embodiment, the computer program can be downloaded and installed from a network via the communication section 1009, and / or installed from the removable medium 1011. When the computer program is executed by the processor 1001, the above-described functions defined in the system of the embodiment of the present disclosure are performed. According to the embodiment of the present disclosure, the systems, devices, means, modules, units, etc. described above can be implemented by computer program modules.

[0117] According to an embodiment of the present disclosure, the program code for executing the computer program provided by the embodiment of the present disclosure can be written in any combination of one or more programming languages. Specifically, these computer programs can be implemented using high-level procedural and / or object-oriented programming languages, and / or assembly / machine languages. Programming languages ​​include, but are not limited to, languages ​​such as Java, C++, python, "C" or similar programming languages. The program code can be executed entirely on the user computing device, partially on the user device, partially on a remote computing device, or entirely on a remote computing device or server. In cases involving a remote computing device, the remote computing device can be connected to the user computing device through any type of network, including a local area network (LAN) or a wide area network (WAN), or can be connected to an external computing device (for example, using an Internet service provider to connect via the Internet).

[0118] The flowcharts and block diagrams in the accompanying drawings illustrate the possible implementation architecture, functions and operations of the systems, methods and computer program products according to various embodiments of the present disclosure. In this regard, each box in the flowchart or block diagram can represent a module, program segment, or a part of code, and the above-mentioned module, program segment, or a part of code contains one or more executable instructions for implementing the specified logical function. It should also be noted that in some alternative implementations, the functions marked in the box can also occur in an order different from that marked in the accompanying drawings. For example, two boxes represented in succession can actually be executed substantially in parallel, and they can sometimes be executed in the opposite order, depending on the functions involved. It should also be noted that each box in the block diagram or flowchart, and the combination of boxes in the block diagram or flowchart, can be implemented with a dedicated hardware-based system that performs the specified function or operation, or can be implemented with a combination of dedicated hardware and computer instructions.

[0119] Those skilled in the art will appreciate that the features described in the various embodiments and / or claims of this disclosure may be combined and / or coupled in various ways, even if such combinations and / or couplings are not explicitly described in this disclosure. In particular, the features described in the various embodiments and / or claims of this disclosure may be combined and / or coupled in various ways without departing from the spirit and teachings of this disclosure. All such combinations and / or couplings are intended to fall within the scope of this disclosure.

[0120] The embodiments of the present disclosure have been described above. However, these embodiments are for illustrative purposes only and are not intended to limit the scope of the present disclosure. Although the present disclosure has been shown and described with reference to specific exemplary embodiments of the present disclosure, it should be understood by those skilled in the art that various changes in form and details may be made to the present disclosure without departing from the spirit and scope of the present disclosure as defined by the appended claims and their equivalents. Therefore, the scope of the present disclosure should not be limited to the above-described embodiments, but should be determined not only by the appended claims, but also by the equivalents of the appended claims.

Claims

1. A MySQL database management method, characterized in that: include: When the status of the server where the MySQL database is located meets a preset condition, obtaining the SQL statements in the MySQL database and the execution status of the SQL statements, wherein the execution status of the SQL statements includes the execution thread number of each SQL statement; Based on the SQL statement and the execution status of the SQL statement, construct an operation status topology diagram of the MySQL database; Obtain the total number of threads currently executing in the MySQL database through the operation status topology diagram of the MySQL database; When the total number of threads exceeds a preset first threshold, determining that the MySQL database is in an abnormal state; when the MySQL database is in an abnormal state, determining and processing all SQL statements in the MySQL database that are in an abnormal state; By utilizing the operation status topology diagram of the MySQL database, all SQL statements in the MySQL database that are in abnormal status are determined and processed.

2. The MySQL database management method according to claim 1, wherein: When the status of the server where the MySQL database is located meets a preset condition, before obtaining the execution status of the SQL statement in the MySQL database, the method further includes: Periodically obtain the memory usage, CPU usage and MySQL database process of the server; Determine whether the memory usage, CPU usage, and process of the MySQL database of the server meet preset conditions.

3. The MySQL database management method according to claim 2, wherein: The preset conditions are: A change value of at least one of the memory usage, CPU usage, and process of the MySQL database of the server exceeds a corresponding preset threshold.

4. The MySQL database management method according to claim 1, wherein: The determining and processing of all abnormal SQL statements in the MySQL database specifically includes: When a currently executed SQL statement is in a locked state, it is determined that the currently executed SQL statement is in an abnormal state; When there is a SQL statement currently being executed whose execution time exceeds a preset second threshold, it is determined that the SQL statement currently being executed is in an abnormal state; Terminates the execution of all SQL statements that are in an abnormal state.

5. A MySQL database management device, characterized in that: include: An acquisition module, configured to acquire SQL statements in the MySQL database and the execution status of the SQL statements when the status of the server where the MySQL database is located meets a preset condition, wherein the execution status of the SQL statements includes the execution thread number of each SQL statement; A construction module, configured to construct an operation status topology diagram of the MySQL database based on the SQL statement and the execution status of the SQL statement; A processing module is used to obtain the total number of threads currently executed in the MySQL database through the operation status topology diagram of the MySQL database; When the total number of threads exceeds a preset first threshold, the MySQL database is determined to be in an abnormal state; when the MySQL database is in an abnormal state, all SQL statements in the MySQL database that are in an abnormal state are determined and processed; and using the operating status topology diagram of the MySQL database, all SQL statements in the MySQL database that are in an abnormal state are determined and processed.

6. An electronic device, characterized in that: The electronic device comprises: one or more processors; a memory for storing one or more programs, When the one or more programs are executed by the one or more processors, the one or more processors execute the MySQL database management method according to any one of claims 1 to 4.

7. A computer-readable storage medium having executable instructions stored thereon, which, when executed by a processor, causes the processor to execute the MySQL database management method according to any one of claims 1 to 4.

8. A computer program product, comprising a computer program, wherein when the computer program is executed by a processor, the computer program implements the MySQL database management method according to any one of claims 1 to 4.

Citation Information

Patent Citations

  • Structured query statement positioning method and device, computer device and storage medium

    CN110209688A

  • Database operation control method and system based on SQL optimization and storage medium

    CN113282574A