How to Read MySQL Binary Log Files (BinLog) with mysqlbinlog Como ler o MySQL Log Binário Files (BinLog) com 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. Banco de dados MySQL binary gera arquivos de log de cada operação para os bancos de dados, desde administrador não desativar ou comentar as "log-bin" parâmetro my.cny no arquivo de configuração. The binary log files are written in binary format. O log binário arquivos são escritos em formato binário. 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. Embora os logs binários, ou também conhecido como logbin são usadas principalmente para a replicação de dados MySQL efeito, às vezes pode ser necessário estudar ou ler o conteúdo dos logs binários em formato de texto, onde o utilitário mysqlbinlog será útil.
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ário arquivo de registro, que normalmente tem nome com o formato host_name-bin.xxxxxx e armazenar em / var / lib / mysql diretório, não poderiam ser abertos e lidos imediatamente como ele é ilegível, em formato binário. 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 ler os logs binários em formato de texto, podemos fazer uso do comando mysqlbinlog, que também capaz de readrelay arquivos de registro escrito por um servidor em uma replicação slave setup. Relay logs have the same format as binary log files. Relay logs têm o mesmo formato binário arquivos de log.
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 usar o utilitário mysqlbinlog é simples, basta utilizar o seguinte comando sintaxe para invocar mysqlbinlog após login como root (senão você tem que especificar o nome do usuário e senha) para a casca via SSH:
mysqlbinlog [options] log_file … mysqlbinlog [opções] log_file…
So to read and display the contents of the binary log file named binlog.000001, use this command: Então, para ler e exibir o conteúdo do log binário arquivo chamado binlog.000001, use 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. O log binário seus arquivos e dados são susceptíveis de ser muito grande, tornando assim quase impossível de ler nada na tela. 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: No entanto, você pode canalização para a saída do mysqlbinlog em um arquivo que pode ser aberto até mais tarde para navegar no editor de texto, utilizando o seguinte 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 reduzir a quantidade de dados extraídos de logs binários, existem várias opções que podem ser utilizadas para limitar os dados que tem sido devolvidos. Among the useful ones are listed below: Entre os mais úteis são listados a seguir:
–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. Começar a ler o log binário no primeiro evento com uma hora mais tarde do que igual ou datetime o argumento. The datetime value is relative to the local time zone on the machine where you run mysqlbinlog. O valor datetime é relativo ao fuso horário local na máquina onde é executado mysqlbinlog. The value should be in a format accepted for the DATETIME or TIMESTAMP data types. O valor deve ser aceito em um formato DATETIME ou TIMESTAMP para os tipos de dados. For example: Por exemplo:
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. Parar a leitura do log binário ao primeiro evento ter um timestamp igual ou posterior à datetime argumento. This option is useful for point-in-time recovery. Esta opção é útil para ponto-in-time recuperação. See the description of the –start-datetime option for information about the datetime value. Consulte a descrição do-start-datetime opção para obter informações sobre o valor datetime.
–start-position=N - Start-posição N =
Start reading the binary log at the first event having a position equal to the N argument. Iniciar a leitura do log binário ao primeiro evento tendo uma posição igual à N argumento. This option applies to the first log file named on the command line. Esta opção aplica-se ao primeiro log arquivo chamado na linha de comando.
–stop-position=N - Stop-posição N =
Stop reading the binary log at the first event having a position equal or greater than the N argument. Parar a leitura do log binário ao primeiro evento tendo uma posição igual ou maior do que o N argumento. This option applies to the last log file named on the command line. Esta opção aplica-se ao último log arquivo chamado na linha de comando.
For more usage information on mysqlbinlog, visit Para obter mais informações sobre a utilização mysqlbinlog, visite here aqui .
IMPORTANT : This is a machine translated page which is provided "as is" without warranty. IMPORTANTE: Esta é uma página traduzida máquina que é fornecida "como está" sem garantia. Machine translation may be difficult to understand. A tradução automática pode ser difícil de compreender. Please refer to Por favor, consulte a original English article Inglês original article whenever possible. sempre que possível.
Share and contribute or get technical support and help at Compartilhe e contribuir ou obter suporte técnico e ajudar a My Digital Life Forums Minha vida digital Fóruns .
Related Articles Artigos relacionados
- Change or Set MySQL Long Query Time Value for log-slow-queries Alterar ou definir o MySQL Query Long Time Valor para log-slow-queries
- Enable Logging of Slow Queries (Slow Query Log) in MySQL Database Ativar registro de Consultas Lento (Slow Query Log) no MySQL Database
- How to Backup and Restore (Export and Import) MySQL Databases Tutorial Como a Backup e Restauração (de Importação e Exportação) Bancos de dados MySQL Tutorial
- Install Web Server in Windows XP with Apache2, PHP5 and MySQL4 - Part 1 Instalar Web Server no Windows XP com Apache2, PHP5 e MySQL4 - Parte 1
- Reset the Root Password of MySQL Server Redefinir a senha do root do servidor MySQL
- MySQL Database Performance Tuning Best Practices Video Tutorial Banco de dados MySQL Performance Tuning melhores práticas vídeo tutorial
- Installing Web Server in FreeBSD 6.0 with Apache 2.2, MySQL 5.0 and PHP 5 - Part 3 Instalando Web Server no FreeBSD 6,0 a 2,2 Apache, MySQL e 5,0 PHP 5 - Parte 3
- Install Web Server in Windows XP with Apache2, PHP5 and MySQL4 - Part 4 Instalar Web Server no Windows XP com Apache2, PHP5 e MySQL4 - Parte 4
- Change and Reset MySQL root Password Mudança e Reset MySQL raiz Senha
- How to Find and Replace Text in MySQL Database using SQL Como Localizar e substituir texto em SQL usando o MySQL Database

































June 29th, 2008 16:33 29 de junho 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 post salvou minha vida hoje… quando o log binário foi a única maneira de recuperar dados importantes se perdem… agradece!