2. How to know the current log
mysql> show master status;
3. Look at the binary log file with Mysqlbinlog
shell>mysqlbinlog mail-bin.000001
How do I open a binary query?
By default, the binary log is turned off, and you can start and set up the binary log by modifying the MySQL configuration file:
There are several settings in the MY.CNF [mysqld] group that are related to the binary log:
log-bin[=PATH/[FILENAME]]
expire_logs_days=10
max_binlog_size=100M
server-id = 1//这一行必须要,因为数据库有主从之分
log-bin
Define open binary log; path indicates the directory where the log file resides;
filename Specifies the name of the log file, such as the full name of the file is filename.0001,filename.0002, etc.
In addition to the above file, there is a file that becomes Filename.index, the file content is a list of all logs, you can use Notepad to open the file
expire_logs_days
Defines the time that MySQL clears an expired log, that is, the number of days that the binary log is automatically deleted. The default value is 0, which means "no automatic deletion". The file may be deleted when MySQL starts or refreshes the binary log
max_binlog_size
Defines the size limit for a single file, which scrolls if the contents of the binary log are written beyond the given value
(Close the current file and reopen a new log file.) You cannot set this variable to be greater than 1GB or less than 4096 bytes. The default value is 1GB
How do I turn on slow queries?
If the log_slow_queries
status is off, no slow query is currently turned on.
It is very simple to turn on slow queries, as follows:
In [mysqld], add the following information:
[mysqld]
log-slow-queries[=PATH/[FILENAME]]
long_query_time = 4
log-queries-not-using-indexes
log-slow-queries
: On behalf of the MySQL slow query log storage directory, this directory file must have write permission;
long_query_time
: Maximum execution time. (, MSYQL will record all the execution time more than 2 SQL statements, here is the test time, the time should not be too small preferably within 5-10 seconds, of course, according to their own standards);
log-queries-not-using-indexes
: Queries that do not use an index are also recorded in the log
Configure the MySQL service to restart later
service mysqld restart
From for notes (Wiz)
MySQL log operations