Google+

Enable Binary logs on Mysql

1

August 12, 2012 by harshalvaidya

How To Enable Logs in MySQL Server in Linux

Thelog especially binary logs contains events that describe detailed information about data i.e..database modified such as table creation operations or changes to table data. It also contains events for statements that potentially could have made changes eg.. DELETE which matched no rows). It also contains information about how long each statement took that updated data.

Purpose of Logs :-

1) Replication :
the binary log is used on master replication servers as a record of the statements to be sent to slave servers. The master server sends the events contained in its binary log to its slaves, which execute those events to make the same data changes that were made on the master.

2) Data Recovery :
Certain data recovery operations require use of the binary log. After a backup has been restored, the events in the binary log that were recorded after the backup was made are re-executed. These events bring databases up to date from the point of the backup.

3) Tracking :
It helps in tracking exact operations performed on the databases
##################################
Step:1 Stop the mysql service using below command
##################################
# service mysqld stop

###############################################
Step:2 Edit the mysql configuration files (/etc/my.cnf) and add below lines
###############################################
log-bin = /var/lib/mysql/<application-name>-mysql-bin.log
OR
log-bin=mysql-bin
expire_logs_days = 2
# binary logging format – mixed recommended
binlog_format=mixed

#####################################
Step:3 Now start the mysql service using below command
#####################################
service mysqld start

 

log-bin=mysql-bin :- The logs will go to the mysql data directory and will have the mysql-bin prefix if we use log-bin=mysql-bin or else we can mention the path.
expire_logs_days:- System variable to expire binary log files automatically after a given number of days.

Advertisements

One thought on “Enable Binary logs on Mysql

  1. i was looking for such easy task from a long time it will help me in increasing my knowledge. thanks a lot. lista de email lista de email lista de email lista de email lista de email

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

Blog Stats

  • 774 hits

stat

var infolink_pid = 1084591; var infolink_wsid = 0;
%d bloggers like this: