How to record SQL logs in MySQL (for example, SQL Server Profiler)

Source: Internet
Author: User
Tags ultraedit
SQL Server has an SQL profiler that can track the SQL statements executed by the server in real time, which is useful in many times for debugging errors. For example, the complexity of othersCode, Production system, no debugging environment, no original code ...... After checking the information, My SQL can use the following method to track SQL statements. The following method is similar to that of Linux on the Windows platform: 1. Configure the my. ini file (in the installation directory, the file name in Linux is my. CNF Find the [mysqld] section and add the log configuration, as shown in the following example: [Mysqld]
Log = "C:/temp/MySQL. log"
Log_slow_queries = "C:/temp/mysql_slow.log"
Long_query_time = 1 Log indicates the directory where log files are stored; Log_slow_queries indicates the SQL log directory that records the execution time; Long_query_time indicates the execution time, in seconds. In Linux, these configuration items should already exist, but are commented out. You can remove the annotations. However, it is okay to add configuration items directly. 2. Restart the MySQL service. Note: The a log storage directory must exist in advance; otherwise, logs cannot be recorded. The situation also exists here. C:/TEMP directory must already exist. B. The log file is in Linux format. We recommend that you use ultraedit to open it and convert it to DOS format for viewing (otherwise there will be no line breaks and you cannot understand them) Service C cannot delete log files when it is started; otherwise, it cannot record SQL statements. D. You cannot use ultraedit to directly clear the file content and save it. Otherwise, the file cannot be recorded. You need to restart the service. If ultraedit saves. Bak, it will be recorded in this file. E. You can use NotePad to clear text and save it. You can continue to record logs. (Strange, not recommended)
Related Article

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.