The world's most popular open source database
You can use the options to mysqld that are described in this section to affect the operation of the binary log as well as to control which statements are written to the binary log. For additional information about the binary log, see Section 5.2.3, “The Binary Log”.
Core options. The following list provides information about options for enabling and configuring the binary log:
Enable binary logging. The server logs all statements that change data to the binary log, which is used for backup and replication. See Section 5.2.3, “The Binary Log”.
The option value, if given, is the basename for the log
sequence. The server creates binary log files in sequence by
adding a numeric suffix to the basename. It is recommended
that you specify a basename (see Section B.1.8.1, “Open Issues in MySQL”,
for the reason). Otherwise, MySQL uses
as the basename.
host_name-bin
The index file for binary log filenames. See
Section 5.2.3, “The Binary Log”. If you omit the filename, and if
you didn't specify one with --log-bin, MySQL
uses
as the filename.
host_name-bin.index
| Option Sets Variable | Yes, max_binlog_cache_size
|
||||||
| Variable Name | max_binlog_cache_size |
||||||
| Variable Scope | Global | ||||||
| Dynamic Variable | Yes | ||||||
| Value Set |
|
If a multiple-statement transaction requires more than this
many bytes of memory, the server generates a
Multi-statement transaction required more than
'max_binlog_cache_size' bytes of storage error. The
minimum value is 4096, the maximum and default values are 4GB.
| Option Sets Variable | Yes, max_binlog_size
|
||||||
| Variable Name | max_binlog_size |
||||||
| Variable Scope | Global | ||||||
| Dynamic Variable | Yes | ||||||
| Value Set |
|
If a write to the binary log causes the current log file size to exceed the value of this variable, the server rotates the binary logs (closes the current file and opens the next one). You cannot set this variable to more than 1GB or to less than 4096 bytes. The default value is 1GB.
A transaction is written in one chunk to the binary log, so it
is never split between several binary logs. Therefore, if you
have big transactions, you might see binary logs larger than
max_binlog_size.
If max_relay_log_size is 0,
the value of max_binlog_size
applies to relay logs as well.
| Version Introduced | 5.0.1 | ||||||
| Option Sets Variable | Yes, sync_binlog
|
||||||
| Variable Name | sync_binlog |
||||||
| Variable Scope | Global | ||||||
| Dynamic Variable | Yes | ||||||
| Value Set |
|
If the value of this variable is greater than 0, the MySQL
server synchronizes its binary log to disk (using
fdatasync()) after every
sync_binlog writes to the binary log. There
is one write to the binary log per statement if autocommit is
enabled, and one write per transaction otherwise. The default
value of sync_binlog is 0, which does no
synchronizing to disk. A value of 1 is the safest choice,
because in the event of a crash you lose at most one statement
or transaction from the binary log. However, it is also the
slowest choice (unless the disk has a battery-backed cache,
which makes synchronization very fast).
If the value of sync_binlog is 0 (the
default), no extra flushing is done. The server relies on the
operating system to flush the file contents occasionally as
for any other file.
Additional server options, that can be used to control logging, also affect the binary log. For more information about these, see Section 5.1.2, “Server Command Options”.
Statement selection options. The options in the following list affect which statements are written to the binary log, and thus sent by a replication master server to its slaves.
Tell the server to restrict binary logging to updates for
which the default database is
db_name (that is, the database
selected by USE). All other
databases that are not explicitly mentioned are ignored. If
you use this option, you should ensure that you do updates
only in the default database.
There is an exception to this for CREATE
DATABASE, ALTER
DATABASE, and DROP
DATABASE statements. The server uses the database
named in the statement (not the default database) to decide
whether it should log the statement.
An example of what does not work as you might expect: If the
server is started with binlog-do-db=sales,
and you run USE prices; UPDATE sales.january SET
amount=amount+1000;, this statement is
not written into the binary log.
To log multiple databases, use this option multiple times, specifying the option once for each database to be logged.
Tell the server to suppress binary logging of updates for
which the default database is
db_name (that is, the database
selected by USE). If you use
this option, you should ensure that you do updates only in the
default database.
As with the --binlog-do-db option, there is
an exception for the CREATE
DATABASE, ALTER
DATABASE, and DROP
DATABASE statements. The server uses the database
named in the statement (not the default database) to decide
whether it should log the statement.
An example of what does not work as you might expect: If the
server is started with
binlog-ignore-db=sales, and you run
USE prices; UPDATE sales.january SET amount = amount
+ 1000;, this statement is
written into the binary log.
To ignore multiple databases, use this option multiple times, specifying the option once for each database to be ignored.
--log-bin-trust-function-creators[={0|1}]
| Version Introduced | 5.0.16 | ||||
| Option Sets Variable | Yes, log_bin_trust_function_creators
|
||||
| Variable Name | log_bin_trust_function_creators |
||||
| Variable Scope | Global | ||||
| Dynamic Variable | Yes | ||||
| Value Set |
|
With no argument or an argument of 1, this option sets the
log_bin_trust_function_creators
system variable to 1. With an argument of 0, this option sets
the system variable to 0.
log_bin_trust_function_creators
affects how MySQL enforces restrictions on stored function and
trigger creation. See
Section 18.5, “Binary Logging of Stored Programs”.
This option was added in MySQL 5.0.16.
--log-bin-trust-routine-creators[={0|1}]
| Version Introduced | 5.0.6 | ||||
| Option Sets Variable | Yes, log_bin_trust_routine_creators
|
||||
| Variable Name | log-bin-trust-routine-creators |
||||
| Variable Scope | Global | ||||
| Dynamic Variable | Yes | ||||
| Deprecated | 5.0.16, by log-bin-trust-function-creators
|
||||
| Value Set |
|
This is the old name for
--log-bin-trust-function-creators. Before
MySQL 5.0.16, it also applies to stored procedures, not just
stored functions and sets the
log_bin_trust_routine_creators system
variable. As of 5.0.16, this option is deprecated. It is
recognized for backward compatibility but its use results in a
warning.
This option was added in MySQL 5.0.6.
Whether updates received by a slave server from a master server should be logged to the slave's own binary log. Binary logging must be enabled on the slave for this variable to have any effect. See Section 16.1.2.3, “Replication Slave Options and Variables”.
For more detailed information about how the options in the previous list are applied, see Section 5.2.3, “The Binary Log”.
There are also options for slave servers that control which statements received from the master should be executed or ignored. For details, see Section 16.1.2.3, “Replication Slave Options and Variables”.
Testing and debugging options. The following binary log options are used in replication testing and debugging. They are not intended for use in normal operations.


User Comments
Add your own comment.