The story of "experimental summary six" MySQL log

Source: Internet
Author: User

Open binary log (binary log content: Change the operation of the database)

In the/ETC/MYSQL/MY.CNF

Remove the comment from the Log_bin line to open the following is the saved path

The following expire_logs_days is how long, MySQL automatically deletes the binary log

Max_binlog_size is the largest binary log size

Note that the changes just after restarting MySQL will take effect.

Shell>sudo service MySQL Stop

Shell>sudo service MySQL Start

Then log in to MySQL

A binary log is generated after each login

My binary log is specifically

mysql-bin.000001 (MySQL here for host name)

Can be used in MySQL: Show BINARY logs to view

See what you need in the shell: for example

mysqlbinlog/var/log/mysql/mysql-bin.0000002

To view

Delete all log files (a new binary log file is also generated):

Mysql>reset MASTER;

To delete the specified log file:

Mysql>purge MASTER LOGS to ' mysql-bin.0000002 ';


To is to the meaning so above that sentence for delete mysql-bin.0000001


can also be partially deleted based on time

: Mysql>purge MASTER LOGS before ' 20150531 ';


Recovering data from binary logs:

Shell>mysqlbinlog--stopdatetime= "2015-05-31 10:18:15"/var/log/mysql/mysql-bin.000002|mysql-u root-p

Where time is the time in the binary log


Pause binary log:

Mysql>set Sql_log_bin=off;

To restore a binary log:

Mysql>set Sql_log_bin=on;

"Effect of flush logs: More than one new log file will be generated"


So the instructions above will be used when the binary log is opened.


Turn on the error log (suffix. err)

Also in My.cnf, let Log_error's comments be canceled.

To view the path where the error log is located

Mysql>show variables like ' log_error '

To delete the error log:

Shell>mysqladmin-u root-p Flush-logs

Or:

Mysql>flush logs


To start the Universal query log (common query log: User-to-database steps):

In the same vein [mysqld]

Riga: Log

Delete/actually re-create:

Mysqladmin-u root-p Flush-logs


Start slow query log (slow query log content: Queries that execute longer than long_query_time or queries that do not use an index)

Start set slow query log: The same as the previous

Add in MY.CNF: log-slow-queries (use its default data path without specifying a path later)

Regenerate slow query log files

Shell>mysqladmin-u root-p Flush-logs

Mysql>flush logs

"Slow query log is related to performance optimization"


The story of "experimental summary six" MySQL log

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.