How do I turn on Binlog in MySQL? Open binary log file? binary logs?

Source: Internet
Author: User
Tags documentation log log mysql version

Requirements Description :

Turn on MySQL binlog that is the binary log log function, which is recorded here.

Version Description :

    • MySQL version: 5.7.21-log

Operation Process :

1. Modify the my.cnf and add the following parameters to restart the MySQL instance

server-id=11           #由于bug, so you need to set this parameter. Otherwise, the MySQL instance cannot be started log-bin = Mysql-bin    # Where Mysql-bin represents basename is the prefix portion of the generated binary log file, the default location is in the DataDir directory, or it can be set to a different path

2. View Binlog related system parameter values

Mysql>Show variableswhereVariable_nameinch('Log_bin','Log_bin_basename','Log_bin_index');+------------------+-----------------------------+|Variable_name|Value|+------------------+-----------------------------+|Log_bin|  on                          ||Log_bin_basename| /Mysql/Data/Mysql-Bin||Log_bin_index| /Mysql/Data/Mysql-Bin.Index |+------------------+-----------------------------+3Rowsinch Set(0.00Sec

Note: After setting up Log-bin in My.cnf, Log_bin automatically set to On,basename set to Mysql-bin,index file is also automatically generated, index file is the name of all binaries and location information.

3. View the representation of the generated binaries on the file system

[[email protected] data]# ls-ltr mysql-bin.*-rw-r-----1 mysql mysql 154 Jul 11:17 mysql-bin.000001-rw-r-----1 mysql MySQL  11:17 mysql-bin.index

Note: Mysql-bin is a set of basename, the sequence number after the dot is automatically generated, start, automatically generate the first file, when the file is full, will write 2, then 3, and so on.

4. View the contents of the index file

[[email protected] data]# cat mysql-bin.index    #如果mysql-bin is not in the default path, the absolute path plus file name is recorded in the index file . mysql-bin.000001

5. Precautions

In the official documentation, it is said that enabling binary log only requires the Log-bin=mysql-bin setting, but because of the bug, you must set the Server-id otherwise the startup is unsuccessful.

The official documentation is explained below :

6. If the MY.CNF Log-bin does not add basename

server-id=11 log-bin               #后面不接basename

7. Restart MySQL instance to view Log-bin related information

Mysql> Show variables where variable_name in (' Log_bin ', ' log_bin_basename ', ' log_bin_index '); +------------------+- -----------------------------+| Variable_name    | Value                        |+------------------+------------------------------+| log_bin          | On                           | | log_bin_basename |/mysql/data/testvm-bin       | | log_bin_index    |/mysql/data/TESTVM -bin.index |+------------------+------------------------------+3 rows in Set (0.01 sec)

Note: If you do not add basename, then is the hostname-bin, host name-bin.index such a way of naming.

Document creation time: July 19, 2018 15:06:57

How do I turn on Binlog in MySQL? Open binary log file? binary logs?

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.