Recent life has a big change, so the blog has been shelved for a long time did not write, as if blogging has become a habit, put aside a period of time there is so little sense of crisis, the heart always feel uncomfortable. So from today on or continue to pick up the pen (keyboard), continue to maintain the blog, write the most real ideas in mind, write some of the people and things in contact with some of the new technology. Of course, blogging is not purely for the record, but also want to make more friends through the blog, today in the company library to see a sentence roughly said is "in today's era, it is difficult to wait until Sangumaolu, Zhuge Liang also need blogs, Weibo and influence", A year ago I had thought of writing an article on how to improve the personal influence through the blog, I will take the time to write this month as soon as possible, and also recently read a few books, some time to recommend to everyone. Write the content of the book today to write to the database monitoring, here is roughly the content to the blog, the database SQL execution process Monitoring There are many scenarios can be used, such as my book said the code audit scene, in addition to some of the troubleshooting scenarios, through the real-time audit database, can quickly locate the problem. Here is the main talk about MySQL and MSSQL implementation monitoring. The main principle of monitoring in MySQL is to open MySQL General_log to record the history of MySQL execution statement, it has two records, by default, by logging to the file mode, and the other is directly recorded in the MySQL Library general_log table, For a more convenient query, I chose the way to log to the MySQL database. In addition, this feature can be opened in two ways, one is directly with the MySQL SQL statement opened, SQL statements as follows
Set global general_log=on; SET GLOBAL log_output= ' table ';
However, these steps are automatically completed in the blogger's code audit system, and it also supports fast filtering of real-time previews. Just click Down and click Update to see all the SQL statements executed in MySQL during this time, the main interface diagram is as follows
MSSQL performs monitoring, with a performance monitoring tool on SQL Server Profiler, which can be found in the Start menu, and SQL Server Profiler can save SQL execution to files and database tables. It also supports real-time viewing and searching.
Let's take a look at how to use it, open SQL Server Profiler, in the upper left corner of the menu bar, select "File", "New tracking", in the general column after entering the tracking name (optional), you can choose to record to the file and record to the database table two records in the way, When you have chosen, click on the "Event Selection" tab, select the event you want to log as needed, I will only keep the sql:batchcompleted event below the TSQL in the event selection, then click "Run"
Run post-monitoring to the SQL statement as shown:
SQL monitoring: MySQL and MSSQL database SQL execution Process monitoring audit