How to Read MySQL Binary Log Files (BinLog) with mysqlbinlog Ako Čítať MySQL Binárny log súbory (BinLog) s 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. Databázový server MySQL generuje binárne súbory protokolu pre každú transakciu do databázy, ak správca nie je zakázať alebo zakomentujte "log-bin" my.cny parameter v konfiguračnom súbore. The binary log files are written in binary format. Binárne súbory protokolu sú písané v binárnom formáte. 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. Hoci člen určitý binárne logs, alebo tiež známy ako logbin sa používajú hlavne pre replikáciu databázy MySQL účel, niekedy budete musieť preskúmať alebo čítať člen určitý obsah of binárne logs do citát dať do formátu, kde mysqlbinlog nástroj sa bude hodiť.
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. Binárny súbor protokolu, ktorý má zvyčajne meno s formátom host_name-bin.xxxxxx a uložiť do / var / lib / mysql directory, nemožno otvoriť a prečítať hneď, ako je to nečitateľné v binárnom formáte. 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. Ak chcete čítať binárne logs do citát dať do formátu, môžeme využiť mysqlbinlog príkazu, ktorý tiež možnosť readrelay log súbory napísané slave server v nastavení replikácie. Relay logs have the same format as binary log files. Relé protokoly majú rovnaký formát ako binárne súbory protokolu.
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: Ak chcete použiť nástroj mysqlbinlog je jednoduché, stačí použiť nasledujúcu syntax príkazu odvolať mysqlbinlog po prihlásení ako root (inak musíte zadať užívateľské meno a heslo) do shellu cez SSH:
mysqlbinlog [options] log_file ...
So to read and display the contents of the binary log file named binlog.000001, use this command: Takže čítať a zobrazovať obsah binárny súbor protokolu s názvom binlog.000001, použite tento príkaz:
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. Binárne súbory protokolu a jeho dáta môžu byť veľmi veľké, čo je takmer nemožné prečítať niečo na obrazovke. 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: Avšak, môžete potrubia mysqlbinlog výstup do súboru, ktorý možno otvoriť pre neskoršie prezeranie v textovom editore, pomocou nasledujúceho príkazu:
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. Ak chcete znížiť množstvo dát načítaných z binárnej logs, existuje niekoľko možností, ktoré môžu byť použité na obmedzenie dát, ktorá je vrátená. Among the useful ones are listed below: Medzi užitočné, sú uvedené nižšie:
–start-datetime=datetime -Start-datetime = datetime
Start reading the binary log at the first event having a timestamp equal to or later than the datetime argument. Začať čítať binárne log v prvom prípade s timestamp rovná alebo vyššia ako datetime argument. The datetime value is relative to the local time zone on the machine where you run mysqlbinlog. Datetime hodnota je vo vzťahu k miestnym časovom pásme na počítači, kde beží mysqlbinlog. The value should be in a format accepted for the DATETIME or TIMESTAMP data types. Hodnota by mala byť vo formáte prijať pre DATETIME alebo TIMESTAMP dátové typy. For example: Napríklad:
mysqlbinlog --start-datetime="2005-12-25 11:25:56" binlog.000001
–stop-datetime=datetime -Stop-datetime = datetime
Stop reading the binary log at the first event having a timestamp equal or posterior to the datetime argument. Prestať čítať binárne log v prvom prípade s časovou značkou rovnaké alebo neskôr, datetime argument. This option is useful for point-in-time recovery. Táto voľba je užitočná pre point-in-time využitie. See the description of the –start-datetime option for information about the datetime value. Pozri opis-start-datetime voľba pre informácie o datetime hodnotu.
–start-position=N -Start-position = N
Start reading the binary log at the first event having a position equal to the N argument. Začať čítať binárne log v prvom prípade má rovnaké postavenie ako argument N. This option applies to the first log file named on the command line. Táto voľba sa vzťahuje na prvý súbor protokolu s názvom na príkazovom riadku.
–stop-position=N -Stop-position = N
Stop reading the binary log at the first event having a position equal or greater than the N argument. Prestať čítať binárne log v prvom prípade má postavenie rovnaké alebo väčšie ako argument N. This option applies to the last log file named on the command line. Táto voľba sa vzťahuje na posledný záznam v súbore s názvom na príkazovom riadku.
For more usage information on mysqlbinlog, visit Pre viac informácií o využitie mysqlbinlog, navštívte here tady . .
IMPORTANT : The page is machine translated and provided "as is" without warranty. Upozornenie: stránka je stroje preložené a za predpokladu, "ako je" bez záruky. Machine translation may be difficult to understand. Strojový preklad môže byť ťažké pochopiť. Please refer to Nájdete na original English article originál Anglicky artikl whenever possible. ak je to možné.
Related Articles Súvisiace články
- Reset the Root Password of MySQL Server Root Password Reset MySQL server
- Change and Reset MySQL root Password Zmien a Reset MySQL kmeň slová Heslo
- How to Backup and Restore (Export and Import) MySQL Databases Tutorial Až k Zálohovať a navrátiť (Export a Import) MySQL Báza dát Učiteľský
- Installing Web Server in FreeBSD 6.0 with Apache 2.2, MySQL 5.0 and PHP 5 – Part 3 Inštalácia webového servera vo FreeBSD 6.0 s Rýchlo 2.2, MySQL 5.0 a PHP 5 - 3. časť
- Read It Later Read It Later
- Installing Web Server in FreeBSD 6.0 with Apache 2.2, MySQL 5.0 and PHP 5 – Part 5 Inštalácia webového servera vo FreeBSD 6.0 s Rýchlo 2.2, MySQL 5.0 a PHP 5 - 5. časť
- Disable Auto Go To (Jump) To Read More Tag Zakázať Auto Go To (Jump), sa dozviete viac tagov
- Installing Web Server in FreeBSD 6.0 with Apache 2.2, MySQL 5.0 and PHP 5 – Part 4 Inštalácia webového servera vo FreeBSD 6.0 s Rýchlo 2.2, MySQL 5.0 a PHP 5 - 4. časť
- Encouraging Toddlers to Read with LeapFrog's Tag Junior Pal Batoľatá podporou Čítanie s LeapFrog to Tag Junior Pal
- Check and Optimize MySQL Database Automatically with Crontab/Cron Skontrolovať a Optimalizácia MySQL databázu automaticky s crontab / Cron










































September 5th, 2009 05:04 5.září 2009 05:04
don't forget (as i did) to execute mysqlbinlog with a user that has permission to read the binlog or sudo works nicely too. nezabudnite (ako ja) plniť mysqlbinlog s užívateľom, ktorý má oprávnenie na čítanie binlog alebo sudo funguje taky pekne.
June 29th, 2008 16:33 29.Jún 2008 16:33
This post saved my life today… when the binary log were the only way to retrieve important data get lost… thanks!! Tento príspevok mi zachránil život dnes ... keď binárny protokol bol jediný spôsob, ako získať dôležité dáta stratiť ... díky!