Geeks Talk

Prepare for your Next Interview


Welcome to the Geeks Talk forums.

You are currently viewing our boards as a guest which gives you limited access to view most discussions and access our other features. By joining our free community you will have access to post topics, communicate privately with other members (PM), respond to polls, upload content and access many other special features. Registration is fast, simple and absolutely free so please, join our community today!

If you have any problems with the registration process or your account login, please contact contact us.

Restore data from MySQL Binary Log

This is a discussion on Restore data from MySQL Binary Log within the MY SQL forums, part of the Databases category; Hi, I'm new to MySQL. help me to read & restore data from the binary log file.. Thanks in Advance....

Go Back   Geeks Talk > Databases > MY SQL
Register Blogs FAQ Tag Cloud Calendar Mark Forums Read
  #1 (permalink)  
Old 02-23-2009
Junior Member
 
Join Date: Aug 2008
Location: Chennai
Posts: 14
Thanks: 1
Thanked 0 Times in 0 Posts
pmsudha is on a distinguished road
Restore data from MySQL Binary Log

Hi,

I'm new to MySQL.
help me to read & restore data from the binary log file..

Thanks in Advance.
Reply With Quote
Sponsored Links
  #2 (permalink)  
Old 02-23-2009
Expert Member
 
Join Date: Nov 2008
Location: Chennai
Posts: 303
Thanks: 1
Thanked 37 Times in 32 Posts
amitpatel66 is on a distinguished road
Re: Restore data from MySQL Binary Log

How to Read MySQL Binary Log Files (BinLog) with mysqlbinlog
MySQL database server generates binary log files for every transaction to the databases, provided administrator does not disable or comment out the “log-bin” parameter in my.cny configuration file. The binary log files are written in binary format. Although the binary logs, or also known as logbin are mainly used for MySQL database replication purpose, sometimes you may need to examine or read the contents of binary logs in text format, where the mysqlbinlog utility will come in handy.

Binary log file, which normally has name with the format host_name-bin.xxxxxx and store in /var/lib/mysql directory, could not be opened and read straight away as it’s in unreadable binary format. To read the binary logs in text format, we can make use of mysqlbinlog command, which also able to readrelay log files written by a slave server in a replication setup. Relay logs have the same format as binary log files.

To use mysqlbinlog utility is simple, simply use the following command syntax to invoke mysqlbinlog after login in as root (else you have to specify user name and password) to shell via SSH:

mysqlbinlog [options] log_file …

So to read and display the contents of the binary log file named binlog.000001, use this command:

mysqlbinlog binlog.000001

The binary log files and its data are likely to be very huge, thus making it almost impossible to read anything on screen. However, you can pipe the output of mysqlbinlog into a file which can be open up for later browsing in text editor, by using the following command:

mysqlbinlog binlog.000001 > filename.txt

To reduce the amount of data retrieved from binary logs, there are several options that can be used to limit the data that is been returned. Among the useful ones are listed below:

–start-datetime=datetime

Start reading the binary log at the first event having a timestamp equal to or later than the datetime argument. The datetime value is relative to the local time zone on the machine where you run mysqlbinlog. The value should be in a format accepted for the DATETIME or TIMESTAMP data types. For example:

mysqlbinlog --start-datetime="2005-12-25 11:25:56" binlog.000001

–stop-datetime=datetime

Stop reading the binary log at the first event having a timestamp equal or posterior to the datetime argument. This option is useful for point-in-time recovery. See the description of the –start-datetime option for information about the datetime value.

–start-position=N

Start reading the binary log at the first event having a position equal to the N argument. This option applies to the first log file named on the command line.

–stop-position=N

Stop reading the binary log at the first event having a position equal or greater than the N argument. This option applies to the last log file named on the command line.
Reply With Quote
Reply

  Geeks Talk > Databases > MY SQL

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is On
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads

Thread Thread Starter Forum Replies Last Post
Data Transfer: from Access and Excel to MySQL database tomrust Data Warehousing 4 08-10-2009 07:41 AM
Hw to do binary search for characters? rachu_1 C and C++ 0 08-28-2008 08:00 AM
Difference between Binary Semaphore and Mutex.. tejaswi S J Unix/Linux 0 07-11-2008 07:51 AM
AJAX Made Easy - Porting MySQL Data to Ajax Lokesh M AJAX & XML 0 06-20-2008 03:50 PM
What is the next step to restore the data? Geek_Guest Data Warehousing 2 09-20-2007 01:18 AM


All times are GMT -4. The time now is 08:37 AM.


Powered by vBulletin® Version 3.8.4
Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO 3.3.1
Copyright © 2009 GeekInterview.com. All Rights Reserved