MySQL Log operations in Windows

Source: Internet
Author: User
Tags mysql command line

Overview of log file types:
1.
The error log records the problems that occur when you start, run, or stop mysqld.
My. ini configuration information:
# Enter a name for the error log file. Otherwise a default name will be used.
# Log-error = D:/mysql_log_err.txt
2.
Query the Client Connection established by log records and the statements executed.
My. ini configuration information:
# Enter a name for the query log file. Otherwise a default name will be used.
# Log = D:/mysql_log.txt
3.
Statement used to update log records and change data. This log is not supported.
My. ini configuration information:
# Enter a name for the update log file. Otherwise a default name will be used.
# Log-update = D:/mysql_log_update.txt
4.
Binary logs record all statements for changing data. It is also used for replication.
My. ini configuration information:
# Enter a name for the binary log. Otherwise a default name will be used.
# Log-bin = D:/mysql_log_bin
5.
Slow logs record all queries whose execution time exceeds long_query_time seconds or where no index is used.
My. ini configuration information:
# Enter a name for the slow query log file. Otherwise a default name will be used.
# Long_query_time = 1
# Log-Slow-queries = D:/mysql_log_slow.txt

 

Close and enable MySQL logs:

Run the following command to check whether logs are enabled:

Mysql> show variables like 'Log _ % '; + --------------------------------- + bytes + | variable_name | value | + ------------------------------- + bytes + |
Log_bin | off | log_bin_trust_function_creators | off | log_error | c: \ Program Files \ mysql \ MySQL Server 5.0 \ data \ xxq-PC.err | log_queries_not_using_indexes | off | log_slave_updates
| Off | log_slow_queries | off | log_warnings | 1 | + --------------------------------- + if the value of the parameter is off, the service is not enabled. write ini configuration information (my. INI is in the MySQL installation directory), remove the "#" And then restart the MySQL service. to stop the MySQL Log service, you only need. remove the corresponding configuration information in ini, that is, binary log: from the overview, I can see my. the log-bin of ini configuration information does not specify the file extension, because it is not used even if you specify the extension. When MySQL creates a binary log file, it first creates a file named "mysql_log_bin" and named ". index, and create a file named "mysql_log_bin" with the suffix ". 000001. When the MySQL service is restarted once, A file with a suffix of 000001 is added, and the suffix name is incremented by 1. If the log length exceeds the upper limit of max_binlog_size (1 GB by default), a new log file is created; use flushlogs (MySQL Command Line) or execute mysqladmin
-U-p flush-logs (Windows Command Prompt) also creates a new log file. Since binary data is written, normal data cannot be seen when you open a file in Notepad. How can we view it? Use the mysqlbinlog command in the bin directory, for example, Bin> mysqlbinlog D:/mysql_log/logs> mysqlbinlog D:/mysql_log/mysql_bin.000002bin> mysqlbinlog D:/mysql_log/logs> mysqlbin: /mysql_log/mysql_bin.000004bin> mysqlbinlog
D:/mysql_log/mysql_bin.20.05 you can also use the SQL statement to view the binary file directory created by MySQL: mysql> showmasterlogs. For the accurate understanding of log files, you need to read the log file carefully, I will not describe it here! (This article is reproduced in http://blog.sina.com.cn/s/blog_4b93170a0100le9y.html), there is reference value.

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.