How to Read MySQL Binary Log Files (BinLog) with mysqlbinlog Як читати бінарного лог-файлів (Двійковий журнал) з 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 Database Server генерує двійкові файли журналу для кожної транзакції до баз даних, за умови адміністратор не вимкніть або закомментіруйте "Log-Біна" my.cny параметра у файлі конфігурації. The binary log files are written in binary format. S 'журналів записуються в двійковому форматі. 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. Хоча бінарні журнали, чи також відомий як logbin в основному використовуються для цілей реплікації MySQL базу даних, іноді вам може знадобитися, щоб розглянути або прочитати зміст бінарних журналів у текстовому форматі, в якому mysqlbinlog утиліта стане в нагоді.
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.xxxxxx і зберігати в / VAR / LIB / MySQL каталогів, не можуть бути відкриті і читати відразу ж, як читається в двійковому форматі. 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. Для читання бінарних журналів у текстовому форматі, ми можемо використовувати mysqlbinlog команду, яка також може readrelay лог файли написані Слов'янський сервер реплікації установки. 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 простий, просто використовувати наступний синтаксис команди для виклику mysqlbinlog після Увійти в систему як кореневий (інакше ви повинні вказати ім'я користувача і пароль) для оболонки через SSH:
mysqlbinlog [options] log_file ...
So to read and display the contents of the binary log file named binlog.000001, use this command: Тому для читання і відображення вмісту бінарний файл журналу з ім'ям binlog.000001, використовуйте наступну команду:
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 в файлі, який можна відкрити для подальшого перегляду в текстовому редакторі, використовуючи наступну команду:
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-DateTime = DateTime
Start reading the binary log at the first event having a timestamp equal to or later than the datetime argument. Почати читання бінарного журналу в першому випадку з міткою рівною або пізнішої DateTime аргумент. The datetime value is relative to the local time zone on the machine where you run mysqlbinlog. DateTime значення по відношенню до місцевого часу на комп'ютері, де запускається mysqlbinlog. The value should be in a format accepted for the DATETIME or TIMESTAMP data types. Значення має бути у форматі, приймаються на DATETIME або TIMESTAMP типи даних. For example: Наприклад:
mysqlbinlog --start-datetime="2005-12-25 11:25:56" binlog.000001
–stop-datetime=datetime -Стоп-DateTime = DateTime
Stop reading the binary log at the first event having a timestamp equal or posterior to the datetime argument. Зупинка читання бінарних журналів в першому випадку з рівними або мітку на задньому DateTime аргумент. This option is useful for point-in-time recovery. Ця опція корисна для точки по часу відновлення. See the description of the –start-datetime option for information about the datetime value. Дивіться опис-Start-DateTime опцію для отримання інформації про DateTime значення.
–start-position=N -Start-позиції = N
Start reading the binary log at the first event having a position equal to the N argument. Почати читання бінарного журналу в першому випадку з позиції рівного аргументу N. This option applies to the first log file named on the command line. Цей параметр застосовується до першого лог файлу, зазначеного в командному рядку.
–stop-position=N -Стоп-позиції = N
Stop reading the binary log at the first event having a position equal or greater than the N argument. Зупинка читання бінарних журналів в першому випадку з позиції рівною або більшою, ніж аргумент N. This option applies to the last log file named on the command line. Цей параметр застосовується до останній файл журналу, зазначеного в командному рядку.
For more usage information on mysqlbinlog, visit Додаткову інформацію про використання mysqlbinlog, відвідайте here тут . .
IMPORTANT : The page is machine translated and provided "as is" without warranty. ВАЖЛИВО: Сторінка машина переведена і надаються "як є" без гарантії. Machine translation may be difficult to understand. Машинний переклад може бути важким для розуміння. Please refer to Будь ласка, зверніться до original English article оригінальний англійська статтю whenever possible. коли це можливо.
Related Articles Статті за Темі
- Reset the Root Password of MySQL Server Скидання пароля root в MySQL Server
- Change and Reset MySQL root Password Зміни та Скидання пароля MySQL
- How to Backup and Restore (Export and Import) MySQL Databases Tutorial Як резервне копіювання і відновлення (експорт та імпорт) баз даних MySQL Учебник
- Installing Web Server in FreeBSD 6.0 with Apache 2.2, MySQL 5.0 and PHP 5 – Part 3 Установка веб-сервера в FreeBSD 6.0 з Apache 2.2, MySQL 5.0 та PHP 5 - Частина 3
- 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 Установка веб-сервера в FreeBSD 6.0 з Apache 2.2, MySQL 5.0 та PHP 5 - Частина 5
- Disable Auto Go To (Jump) To Read More Tag Відключення автоматичного Go To (Перейти) такого змісту додаткового тега
- Installing Web Server in FreeBSD 6.0 with Apache 2.2, MySQL 5.0 and PHP 5 – Part 4 Установка веб-сервера в FreeBSD 6.0 з Apache 2.2, MySQL 5.0 та PHP 5 - Частина 4
- Encouraging Toddlers to Read with LeapFrog's Tag Junior Pal Заохочення Малюки читати з LeapFrog тегу Junior Pal
- Check and Optimize MySQL Database Automatically with Crontab/Cron Перевірка та оптимізація баз даних MySQL автоматично з Crontab / Cron










































September 5th, 2009 05:04 5 вересня 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. Не забудьте (як і я), щоб виконати mysqlbinlog з користувачем, який має дозвіл на читання або Двійковий журнал Суду теж працює чудово.
June 29th, 2008 16:33 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!! Ця посада врятувала мені життя ... Сьогодні, коли двійкового журналу були єдиним способом отримати важливі дані губляться ... Спасибо!