How to Read MySQL Binary Log Files (BinLog) with mysqlbinlog Come leggere MySQL Binary file di log (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. MySQL database server binario genera file di log per ogni transazione alle basi di dati, a condizione che l'amministratore non disattivare o commentare il "log-bin" parametro my.cny file di configurazione. The binary log files are written in binary format. I file di log binario sono scritti in 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. Anche se il log binario, o anche conosciuto come logbin sono utilizzati principalmente per database MySQL scopo di replica, a volte può essere necessario esaminare o di leggere il contenuto di log binario in formato testo, dove l'utilità mysqlbinlog entrano a portata di mano.
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. File di log binario, che normalmente è il nome con il formato host_name-bin.xxxxxx e conservare in / var / lib / mysql directory, non poteva essere aperto e letto subito come è illeggibile in 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. Per leggere il log binario in formato testo, siamo in grado di avvalersi di mysqlbinlog comando, che anche in grado di readrelay file di log scritto da un server slave in una configurazione di replica. Relay logs have the same format as binary log files. Relè log hanno lo stesso formato file di log binario.
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: Per utilizzare mysqlbinlog utilità è semplice, basta utilizzare il comando seguente sintassi per richiamare mysqlbinlog dopo aver eseguito il login come root (altrimenti si deve specificare il nome utente e password) tramite SSH shell:
mysqlbinlog [options] log_file … mysqlbinlog [opzioni] log_file…
So to read and display the contents of the binary log file named binlog.000001, use this command: In modo di leggere e di visualizzare il contenuto dei file di log binario di nome binlog.000001, utilizzare questo 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. I file di log binario e dei suoi dati sono suscettibili di essere molto grande, rendendo così quasi impossibile leggere qualcosa sullo schermo. 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: Tuttavia, è possibile pipe l'output di mysqlbinlog in un file che può essere aperto per più tardi navigando in editor di testo, utilizzando il seguente comando:
mysqlbinlog binlog.000001 > filename.txt mysqlbinlog binlog.000001> nomefile.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. Per ridurre la quantità di dati estratti da registri binari, ci sono diverse opzioni che possono essere utilizzati per limitare i dati che è stato restituito. Among the useful ones are listed below: Tra gli utili sono quelli elencati di seguito:
–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. Avviare la lettura del binario di log al primo evento che hanno un timestamp pari o entro la datetime argomento. The datetime value is relative to the local time zone on the machine where you run mysqlbinlog. Datetime il valore è relativo al fuso orario locale sulla macchina in cui viene eseguito mysqlbinlog. The value should be in a format accepted for the DATETIME or TIMESTAMP data types. Il valore dovrebbe essere in un formato accettato per la DateTime o TIMESTAMP tipi di dati. For example: Per esempio:
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. Fermare la lettura binaria di log al primo evento che hanno un timestamp pari o posteriore alla datetime argomento. This option is useful for point-in-time recovery. Questa opzione è utile per il punto-in-time di recupero. See the description of the –start-datetime option for information about the datetime value. Vedere la descrizione del-start-datetime opzione per informazioni sul datetime valore.
–start-position=N - Start-posizione = N
Start reading the binary log at the first event having a position equal to the N argument. Avviare la lettura del binario di log al primo caso con una posizione pari al N argomento. This option applies to the first log file named on the command line. Questa opzione vale per il primo file di registro denominato sulla riga di comando.
–stop-position=N - Stop-posizione = N
Stop reading the binary log at the first event having a position equal or greater than the N argument. Fermare la lettura binaria di log al primo caso con una posizione uguale o maggiore di N argomento. This option applies to the last log file named on the command line. Questa opzione vale per l'ultimo file di registro denominato sulla riga di comando.
For more usage information on mysqlbinlog, visit Per ulteriori informazioni su uso mysqlbinlog, visitare here qui .
IMPORTANT : This is a machine translated page which is provided "as is" without warranty. IMPORTANTE: Questa è una pagina tradotta macchina che è fornito "così com'è" senza alcuna garanzia. Machine translation may be difficult to understand. Traduzione automatica può essere difficile da capire. Please refer to Si prega di fare riferimento a original English article articolo originale inglese whenever possible. quando possibile.
Share and contribute or get technical support and help at Condividere e contribuire o ottenere supporto tecnico e assistenza in My Digital Life Forums La mia vita digitale Forum .
Related Articles Articoli correlati
- Change or Set MySQL Long Query Time Value for log-slow-queries Modificare o impostare a lungo MySQL Query Time Rapporto di log-slow-query
- Enable Logging of Slow Queries (Slow Query Log) in MySQL Database Attivare la registrazione di Slow query (query lente Accedi) nel Database MySQL
- How to Backup and Restore (Export and Import) MySQL Databases Tutorial Come fare il backup e ripristino (esportazione e importazione) basi di dati di MySQL Tutorial
- Install Web Server in Windows XP with Apache2, PHP5 and MySQL4 - Part 1 Installare server Web in Windows XP con Apache2, PHP5 e MySQL4 - Parte 1
- Reset the Root Password of MySQL Server Reimpostare la password di root di MySQL Server
- MySQL Database Performance Tuning Best Practices Video Tutorial MySQL database performance tuning migliori pratiche video tutorial
- Installing Web Server in FreeBSD 6.0 with Apache 2.2, MySQL 5.0 and PHP 5 - Part 3 L'installazione di server Web in FreeBSD 6,0 con Apache 2,2, 5,0 MySQL e PHP 5 - Parte 3
- Install Web Server in Windows XP with Apache2, PHP5 and MySQL4 - Part 4 Installare server Web in Windows XP con Apache2, PHP5 e MySQL4 - Parte 4
- Change and Reset MySQL root Password Reset cambiamento e MySQL root Password
- How to Find and Replace Text in MySQL Database using SQL Come trovare e sostituire del testo nel Database MySQL usando SQL

































June 29th, 2008 16:33 29 giugno 2008 16:33
This post saved my life today… when the binary log were the only way to retrieve important data get lost… thanks!! Questo post salvato la mia vita di oggi… quando il binario di log sono stati l'unico modo per recuperare i dati importanti si perdono… grazie!