How to Read MySQL Binary Log Files (BinLog) with mysqlbinlog Kā lasīt MySQL Binary Log faili (BinLog) ar 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. MySQL datu bāzes servera rada bināro log failus par katru darījumu ar datu bāzēm, ja administrators nav izslēgt vai komentārus no "log-bin" parametrs my.cny konfigurācijas failā. The binary log files are written in binary format. Bināro log faili tiek rakstīti binārā formātā. 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. Kaut bināro apaļkokus, vai arī pazīstams kā logbin galvenokārt izmanto MySQL datubāzi replikācijas mērķi, dažkārt Jums var būt nepieciešams pārbaudīt, vai lasīt divkāršo apaļkoku teksta formātā, satura kur mysqlbinlog lietderība noderēs.
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āro log failu, kas parasti ir vārda formāts host_name-bin.xxxxxx un uzglabāt in / var / lib / mysql direktoriju nevarēja atvērt un nolasīt uzreiz, kā tas ir nesalasamībai binārā formātā. 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. Lasīt binārā apaļkoku teksta formātā, mēs varam izmantot mysqlbinlog komandu, kas arī var readrelay log failus raksta vergu servera replikācija setup. Relay logs have the same format as binary log files. Relay baļķi ir tādā pašā formātā kā bināro log failus.
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: Lai izmantotu mysqlbinlog lietderība ir vienkārša, vienkārši izmantojiet šādu komandu sintaksi atsaukties mysqlbinlog pēc autorizēties tik saknes (vēl jums ir jānorāda lietotājvārds un parole), lai apvalks caur SSH:
mysqlbinlog [options] log_file ...
So to read and display the contents of the binary log file named binlog.000001, use this command: Tad, lai lasīt un parādīt uz bināro log saturs Fails binlog.000001, izmantojiet šo komandu:
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āro log failus un tās datiem var būt ļoti liels, tādējādi ir gandrīz neiespējami izlasīt kaut ko uz ekrāna. 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: Tomēr jūs varat caurules izejas mysqlbinlog stājas fails, kuru var atvērt, lai vēlāk pārlūkošanai teksta redaktoru, izmantojot komandu:
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. Lai samazinātu datu apjomu, kas iegūti no binārā baļķi, pastāv vairākas iespējas, ko var izmantot, lai ierobežotu datus, kas tiek nosūtīti atpakaļ. Among the useful ones are listed below: Starp noderīgs tiem ir minēti zemāk:
–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. Noklausītos bināro log ir pirmais pasākums, kuru laikspiedolu vienāds vai vēlāk par datetime arguments. The datetime value is relative to the local time zone on the machine where you run mysqlbinlog. Datetime vērtība ir attiecināta pret vietējo laika joslu mašīna kur jūs darbināt mysqlbinlog. The value should be in a format accepted for the DATETIME or TIMESTAMP data types. Vērtībai jābūt formātā, kas pieņemti DateTime vai Laikspiedols datu tipiem. For example: For example:
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. Jāpārtrauc lasīt bināro log ir pirmais pasākums, kuru laikspiedolu vienāds vai vēlāku datetime argumentu. This option is useful for point-in-time recovery. Šī iespēja ir noderīga point-in-time atgūšanu. See the description of the –start-datetime option for information about the datetime value. Skatīt aprakstu-start-datetime iespēja sniegt informāciju par datetime vērtību.
–start-position=N -Start-position = N
Start reading the binary log at the first event having a position equal to the N argument. Noklausītos bināro log ir pirmais pasākums, kuru stāvoklis ir vienāds ar N argumentu. This option applies to the first log file named on the command line. Šāda iespēja ir attiecināma uz pirmā žurnāla Fails uz komandrindu.
–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. Jāpārtrauc lasīt bināro log ir pirmais pasākums, kuru stāvoklis ir vienāds vai lielāks par N arguments. This option applies to the last log file named on the command line. Šāda iespēja ir attiecināma uz pēdējo log faila nosaukums par komandrindu.
For more usage information on mysqlbinlog, visit Vairāk lietošanas informāciju par mysqlbinlog, apmeklējiet here šeit . .
IMPORTANT : The page is machine translated and provided "as is" without warranty. SVARĪGI: lapa mašīna iztulkot un pasniegts tàds, "kàds tas ir" bez garantijas. Machine translation may be difficult to understand. Mašīntulkošanu var būt grūti saprast. Please refer to Lūdzu, skatiet original English article oriģināls angļu rakstu whenever possible. kad vien iespējams.
Related Articles Saistītie raksti
- Reset the Root Password of MySQL Server Reset root parole MySQL Server
- Change and Reset MySQL root Password Pārmaiņas un Reset MySQL root paroli
- How to Backup and Restore (Export and Import) MySQL Databases Tutorial Kā Rezerves kopēšanas un atjaunošanas (Export un Import) MySQL Databases Tutorial
- Installing Web Server in FreeBSD 6.0 with Apache 2.2, MySQL 5.0 and PHP 5 – Part 3 Instalēšana Web Server 6.0 FreeBSD ar 2.2 Apache, MySQL 5.0 un PHP 5 - Part 3
- Read It Later Lasīt to vēlāk
- Installing Web Server in FreeBSD 6.0 with Apache 2.2, MySQL 5.0 and PHP 5 – Part 5 Instalēšana Web Server 6.0 FreeBSD ar 2.2 Apache, MySQL 5.0 un PHP 5 - Part 5
- Disable Auto Go To (Jump) To Read More Tag Disable Auto Go To (Iet) Lai Read More Tag
- Installing Web Server in FreeBSD 6.0 with Apache 2.2, MySQL 5.0 and PHP 5 – Part 4 Instalēšana Web Server 6.0 FreeBSD ar 2.2 Apache, MySQL 5.0 un PHP 5 - Part 4
- Encouraging Toddlers to Read with LeapFrog's Tag Junior Pal Rosināt staigāt lasīt ar LeapFrog's Tag Junior Pal
- Check and Optimize MySQL Database Automatically with Crontab/Cron Pārbaude un pilnveidošana MySQL Database automātiski ar Crontabula / Cron










































September 5th, 2009 05:04 5 septembris 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. Neaizmirstiet (as I did) izpildīt mysqlbinlog ar lietotāju, kam ir atļauja lasīt binlog vai sudo strādā labi too.
June 29th, 2008 16:33 Jūnijs 29, 2008 16:33
This post saved my life today… when the binary log were the only way to retrieve important data get lost… thanks!! Šo ziņu saglabāti mana dzīve šodien ... kad bināro log bija vienīgais veids, kā iegūt svarīgu datu pazust ... thanks!