How to Enable Binary Logging for MySQL Server on Windows and Linux Machine - MySQL DBA Tutorial

MySQL Binary Logging in MySQL Server


The binary log contains a record of all changes ( CREATE, ALTER, INSERT, UPDATE and DELETE) to the databases, both data and structure.
It consists of a set of binary log files and an index file which contains name of binary log files. The data is saved in binary format.

Binary Log File in Windows:


If Binary logs are enabled without providing the location for binary log file, then by default location for the binary log will be "C:\ProgramData\MySQL\MySQL Server 8.0\Data" and file name will be "HostName-bin.00000x".

To make change for binary log file location and name , you can go to my.ini file on below path
"C:\ProgramData\MySQL\MySQL Server 8.0", Look for
# Binary Logging.
log-bin="ProvideBinaryLogFileName-bin"


Binary Log File in Linux:

The default location for Binary log file for MySQL installed on Linux is /var/lib/MySQL. If you need to make changes to default location and binary file name, you can go to /etc/my.cnf file and update it.

Read Binary Log File: 

To read binary log file in Windows, you need to go to bin folder where mysqlbinlog application exists and then use below command on cmd.

mysqlbinlog -v binary-log-filename.00000X


On Linux, you should be able to run the same command. mysqlbinlog is the program that is used to read the binary log file into more readable format.


MySQL Logging Tutorial - How to Enable Binary Logging in MySQL in Windows and Linux

No comments:

Post a Comment

Note: Only a member of this blog may post a comment.