Team LiB
Previous Section Next Section

mysqlbinlog

The mysqlbinlog program displays the contents of a binary log file in readable format. By default, mysqlbinlog reads local log files directly without connecting to a server. It is also possible to connect to a server and ask it to send log files over the connection. See the description for the --read-from-remote-server option.

The format of binary logs has changed from time to time. To avoid compatibility problems, you may find it necessary to use a version of mysqlbinlog that is at least as recent as your server version.

mysqlbinlog also can read relay logs created by replication slave servers because relay log format is the same as binary log format.

Usage

mysqlbinlog [options] file_name ...

Standard Options Supported by mysqlbinlog

--debug       --host        --port        --socket      --version
--help        --password    --protocol    --user

The --protocol and --socket options were introduced in MySQL 4.1.1.

Options Specific to mysqlbinlog

  • --database=db_name, -d db_name

    Extract statements from the log file only for the named database. This option works only when reading local logs.

  • --disable-log-bin, -D (boolean)

    Include statements in the output that disable binary logging of the update statements in the log. This prevents the statements from being logged again when they are re-executed. This option was introduced in MySQL 4.1.8.

  • --force-read, -f (boolean)

    This option controls what mysqlbinlog does when it reads an event from the binary log that it is unable to recognize. By default, it stops. If this option is enabled, mysqlbinlog continues after logging a warning and discarding the event.

  • --local-load=dir_name, -l dir_name

    Use the given directory as the location in which to create temporary data files for processing LOAD DATA LOCAL statements.

  • --offset=n, -o n

    Skip the first n events in the log file.

  • --position=n, -j n

    Start reading the log file at position n. As of MySQL 4.1.4, this option is deprecated in favor of --start-position.

  • --read-from-remote-server, -R (boolean)

    Read binary log files by making a network connection to a server and asking it to send the logs over the connection. To do this, use the --read-from-remote- server option and give the --host, --password, --port, --protocol, --socket, and --user options as necessary to specify connection parameters. Without --read-from-remote-server, those options are ignored.

  • --result-file=file_name, -r file_name

    Write output to the named file.

  • --short-form, -s

    Show only the statements in the log; omit any extra information in the log that is associated with the statements.

  • --start-datetime=date_time

    Start reading binary log events beginning with the first event that has a time at or later than the given date_time value. date_time should be specified in a legal DATETIME format in the time zone local to the host on which you run mysqlbinlog. Quote the value if necessary for your command interpreter. This option was introduced in MySQL 4.1.4.

  • --start-position=n

    Start reading binary log events at the given position in the first log named on the command line. This option was introduced in MySQL 4.1.4.

  • --stop-datetime=date_time

    Stop reading binary log events beginning with the first event that has a time at or later than the given date_time value. date_time should be specified in a legal DATETIME format in the time zone local to the host on which you run mysqlbinlog. Quote the value if necessary for your command interpreter. This option was introduced in MySQL 4.1.4.

  • --stop-position=n

    Stop reading binary log events at the given position in the last log named on the command line. This option was introduced in MySQL 4.1.4.

  • --to-last-log, -R (boolean)

    When reading log files from a server (which requires the --read-from-remote-server option), this option causes binary logs to be read through the last log of the server, rather than at the end of the last requested binary log. --to-last-log can be used to make sure that you have obtained all binary log information from the server. (However, if you are sending the events to the same server to be processed, this can lead to an infinite loop.) This option was introduced in MySQL 4.1.2.

Variables for mysqlbinlog

The following mysqlbinlog variables can be set using the instructions given in "Setting Program Variables" earlier in this appendix.

  • open_files_limit

    Reserve this many file descriptors. The default value is 64. This variable was introduced in MySQL 4.1.2.

    Team LiB
    Previous Section Next Section