How to record SQL log records in MySql

Source: Internet
Author: User
Tags ultraedit

In the tutorial of www.( www.bkjia.com), 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 complex code written by others, the production system, the debugging environment, and the original code ...... after checking the information, My SQL can use the following method to track SQL statements. The following method takes Windows as an example. linux is similar: 1 Configure my. INI file (in the installation directory, the file name in linux is my. cnf finds the [mysqld] section and adds 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 the log files are stored; log_slow_queries indicates the SQL log directory with a long execution time; long_query_time indicates how long the execution time is, 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. Here is also the situation. C: The/temp directory must already have B log files in linux format. We recommend that you use ultraEdit to open them and convert them to the 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.

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.