Batch export of MySQL database log with shell script

Source: Internet
Author: User
Tags log mysql database backup

Mysqlbinlog

The tool that reads statements from the binary log. Logs of executed statements contained in a binary log file can be used to help recover from a crash.

MySQL database log, there are the following kinds of logs:

1. Error log:-log-error

2. Query log:-log

3. Slow query log:-log-slow-queries

4. Update log:-log-update

5. Binary log:-log-bin

This is a discussion of the MySQL binary log export, import, MySQL binary log full backup, incremental backup.

By default, all logs are created in the MYSQLD data directory, or the option settings for the/ETC/MY.CNF [mysqld] Settings section are manually specified.

Under Linux:

# input in [mysqld]

[Mysqld]   
Log_long_format   
log-bin =/data/mysql/3306/binlog   
binlog_cache_size = 4M
Binlog_format = MIXED   
max_ Binlog_cache_size = 16M
max_binlog_size = 512M
expire_logs_days = 30

Above, open the MySQL binary log and specify the path to save the log.

Binlog Log Open method

Add one line to the My.cnf file (Windows is My.ini).

[Mysqld]

Log-bin=mysqlbin-log #添加这一行就ok了 the name behind the = number, define it yourself.

Then we can do a simple operation of the database after the MySQL data files in the directory to see Binlog files

[Root@jimmyli mysql]# LL

-RW-RW----1 mysql mysql 813255 Nov 18:14 mysqlbin-log.000001

See this similar document, the proof is done.

Second, view the binary log file with the Mysqlbinlog command

Whether logging is enabled

Mysql>show variables like ' log_% ';

How to know the current 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.