in reply to mirroring mySQL database
It will produce a log with a copy of all the commands issued to the server. The long-format business means that before each query there is a comment with information about user, IP, date and time of the query.[mysqld] log-update log-long-format
Parsing this format in Perl is not straightforward but not extremely difficult either.# Time: 011206 9:47:01 # User@Host: john[john] @ [10.10.10.112] INSERT INTO official_holidays (OHDate,OHName) VALUES ( "2000/01/01" , +"New Years Day");
The regex should be fortified a bit, but I am sure you got the idea.#!/usr/bin/perl -w use strict; my $start_copy = 0; while (<>) { next if /^\s+$/; if ((!$start_copy) and (/^# Time: (\d+)\s+(\d+):(\d\d):(\d\d)/)) { my $date = $1; my $hour = $2; # check if date and time are what you need if ((substr($1,4,2) eq "06") and ($hour gt "09")) { $start_copy = 1; } } print if $start_copy; }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Re: mirroring mySQL database
by gmax (Abbot) on Dec 06, 2001 at 16:20 UTC |