Monitoring SQL statements (MySQL)

Source: Internet
Author: User

Recently in the making of a tool site, just look at the structure of the people's car experience, look at their pits, I think our system should have a database monitoring and disaster recovery system.

Online Collection Summary under.

Database design should be small and beautiful, concise, database is only a part of the overall project, such as triggers, stored procedures can be implemented, in the overall project can also be used in the application code to complete. We use MySQL, which is a great place to use it, such as tables, indexes, and transactions, instead of having to use all of its functions. Sub-queries are not allowed in the main library of the production environment prior to MySQL5.6. The performance of the subquery before MySQL5.6 is particularly poor. It is recommended to use the MySQL database after mysql5.6

1. A basic SQL monitoring to see the time-consuming execution of SQL

(1) Open profiling parameter: set profiling=1;
(2) Execute SQL
(3) Obtain information about the profile of multiple query saved in the current system by executing the show PROFILES command. (optional)
(4) Calculate the sum of the previously executed SQL time:

However, the usual SQL connection tool in this way will have hints

(Mysql-front)

2. Turn on MySQL's query log and configure the log path

Location is Mysql.ini

  

Log=c:/appserv/mysql/mysql.log

All of MySQL's SQL operations will be logged to this log.

Linux can be viewed in real time with the command tail-f/var/log/mysql/mysql.log

Windows does not have the tail command to download the Baretail tool for real-time viewing

Monitoring SQL statements (MySQL)

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: info-contact@alibabacloud.com 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.