Enable mysql logging in windows and linux _ MySQL

Source: Internet
Author: User
Enable the mysql log function bitsCN.com in windows and linux

By default, the log management function is not enabled for mysql installation, which makes subsequent maintenance inconvenient.

Check whether logs are enabled
Mysql> show variables like 'log _ bin ';

How to know the current log

Mysql> show master status;

Display the number of binary logs

Mysql> show master logs;

Use mysqlbinlog to view binary log files
Shell> mysqlbinlog mail-bin.000001
Or shell> mysqlbinlog mail-bin.000001 | tail

Specify the log output location in the configuration file.
Windows: the configuration file for Windows is my. ini, which is usually in the MySQL installation directory or c:/Windows.
Linux: the configuration file of Linux is my. cnf, which is usually in/etc.

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

In linux:

In [mysqld ],

Log-error =/usr/local/mysql/log/error. log
Log =/usr/local/mysql/log/mysql. log
Long_query_time = 2
Log-slow-queries =/usr/local/mysql/log/slowquery. log


Windows:

SQL code

In [mysqld ],

# Startup log
Log = "E:/wamp/MySql/mysql_log/mysql. log"
# Error logs
Log-error = "E:/wamp/MySql/mysql_log/mysql. logerror. log"
# It indicates how long the SQL statement will be logged down after execution, which is 2 seconds
Long_query_time = 2
# Slow query logs
Log-slow-queries = "E:/wamp/MySql/mysql_log/slowquery. log"

Long_query_time = 2 -- indicates how long the SQL statement will be logged after execution. here, it is 2 seconds.

Log-slow-queries =/usr/local/mysql/log/slowquery. log -- records slow statements returned by the query.

Log-queries-not-using-indexes = nouseindex. log -- it is a literal meaning that the query with no index is used in the log.

Log = mylog. log -- record all execution statements

As for the accurate understanding of log files, you still need to read them carefully.

BitsCN.com

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.