How to Read MySQL Binary Log Files (BinLog) with mysqlbinlog Cómo leer MySQL archivos de registro binario (binlog) con 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. Servidor de bases de datos MySQL genera archivos de registro binario para cada transacción a las bases de datos, a condición de administrador no desactivar o comentar el "log-bin" parámetro en my.cny archivo de configuración. The binary log files are written in binary format. Los archivos de registro binario están escritos en formato binario. 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. Aunque los logs binarios, o también conocido como logbin se utilizan principalmente para la replicación de bases de datos MySQL fin, a veces, puede que tenga que estudiar o leer el contenido de logs binarios en formato de texto, donde la utilidad mysqlbinlog vendrá muy bien.
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. Archivo de registro binario, que normalmente tiene el nombre con el formato host_name-bin.xxxxxx y almacenar en / var / lib / mysql directorio, no se puede abrir y leer de inmediato como es ilegible en formato binario. 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. Para leer los logs binarios en formato texto, podemos hacer uso de mysqlbinlog comando, que puede utilizarse también para readrelay archivos de registro por escrito de un servidor esclavo en una configuración de replicación. Relay logs have the same format as binary log files. Relay registros tienen el mismo formato binario como archivos de registro.
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: Para utilizar mysqlbinlog utilidad es muy simple, basta con usar la siguiente sintaxis de comandos para invocar mysqlbinlog después de login en el sistema como root (cosa que usted tiene que especificar el nombre de usuario y contraseña) a través de SSH shell:
mysqlbinlog [options] log_file … mysqlbinlog [opciones] log_file…
So to read and display the contents of the binary log file named binlog.000001, use this command: Así que a leer y mostrar el contenido del archivo de registro binario llamado binlog.000001, utilice este comando:
mysqlbinlog 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. Los binarios y archivos de registro de sus datos es probable que sean muy grandes, por lo que resulta casi imposible de leer nada en la pantalla. 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: Sin embargo, puede tubería de la salida de mysqlbinlog en un fichero que puede abrir más tarde para la navegación en editor de texto, utilizando el siguiente comando:
mysqlbinlog binlog.000001 > filename.txt 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. Para reducir la cantidad de datos binarios recuperados de los registros, hay varias opciones que pueden ser utilizados para limitar los datos que se han devuelto. Among the useful ones are listed below: Entre los útiles que se enumeran a continuación:
–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. Empezar a leer el log binario en el primer evento que tenga la fecha igual o posterior a la datetime argumento. The datetime value is relative to the local time zone on the machine where you run mysqlbinlog. El valor datetime es relativo a la zona horaria local en la máquina donde se ejecuta mysqlbinlog. The value should be in a format accepted for the DATETIME or TIMESTAMP data types. El valor debe estar en un formato aceptado para la DATETIME o TIMESTAMP tipos de datos. For example: Por ejemplo:
mysqlbinlog --start-datetime="2005-12-25 11:25:56" binlog.000001 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. Pare leer el log binario en el primer evento que tenga la fecha igual o posterior al argumento datetime. This option is useful for point-in-time recovery. Esta opción es útil para el punto-a-tiempo de recuperación. See the description of the –start-datetime option for information about the datetime value. Véase la descripción de la puesta en marcha de datetime opción para obtener información sobre el valor datetime.
–start-position=N - Start-position = N
Start reading the binary log at the first event having a position equal to the N argument. Empezar a leer el log binario en el primer evento que tenga una posición igual al argumento N. This option applies to the first log file named on the command line. Esta opción se aplica al primer archivo de registro de nombre en la línea de comandos.
–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. Pare leer el log binario en el primer evento que tenga una posición igual o superior al N argumento. This option applies to the last log file named on the command line. Esta opción se aplica a los últimos archivo de registro de nombre en la línea de comandos.
For more usage information on mysqlbinlog, visit Para obtener más información sobre el uso mysqlbinlog, visite here aquí .
IMPORTANT : This is a machine translated page which is provided "as is" without warranty. IMPORTANTE: Se trata de una máquina que traduzca la página se proporciona "tal cual" sin garantía. Machine translation may be difficult to understand. La traducción automática puede resultar difícil de entender. Please refer to Por favor, consulte original English article artículo original Inglés whenever possible. siempre que sea posible.
Share and contribute or get technical support and help at Compartir y contribuir o recibir apoyo técnico y ayudar a My Digital Life Forums Mi vida digital Foros .
Related Articles Artículos relacionados
- Change or Set MySQL Long Query Time Value for log-slow-queries Modificar o establecer a largo MySQL Query Time Value for log-slow-queries
- Enable Logging of Slow Queries (Slow Query Log) in MySQL Database Habilitar registro de consultas Baja (Baja Query Log) en la base de datos MySQL
- How to Backup and Restore (Export and Import) MySQL Databases Tutorial Como copia de seguridad y restaurar (exportaciones e importaciones) Bases de datos MySQL Tutorial
- Install Web Server in Windows XP with Apache2, PHP5 and MySQL4 - Part 1 Instalar Web Server en Windows XP con Apache 2, PHP5 y MySQL4 - Parte 1
- Reset the Root Password of MySQL Server Restablecer la contraseña de root del servidor MySQL
- MySQL Database Performance Tuning Best Practices Video Tutorial Base de datos MySQL para ajustar el rendimiento de Prácticas Recomendadas de vídeo tutorial
- Installing Web Server in FreeBSD 6.0 with Apache 2.2, MySQL 5.0 and PHP 5 - Part 3 Instalación de Web Server en FreeBSD 6,0 con Apache 2,2, 5,0 MySQL y PHP 5 - Parte 3
- Install Web Server in Windows XP with Apache2, PHP5 and MySQL4 - Part 4 Instalar Web Server en Windows XP con Apache 2, PHP5 y MySQL4 - Parte 4
- Change and Reset MySQL root Password Cambio y MySQL Restablecer contraseña de root
- How to Find and Replace Text in MySQL Database using SQL Cómo buscar y reemplazar texto en la base de datos MySQL usando SQL

































June 29th, 2008 16:33 29 de junio de 2008 16:33
This post saved my life today… when the binary log were the only way to retrieve important data get lost… thanks!! Este puesto salvado mi vida… hoy cuando el log binario son el único modo de recuperar los datos importantes se pierden… gracias!