The Binary Log
545
shell>
mv host_name-old.log backup-directory
On Windows, you cannot rename a log file while the server has it open before MySQL 5.0.17. You
must stop the server, rename the file, and then restart the server to create a new log file. As of 5.0.17,
this applies only to the error log. However, a stop and restart can be avoided by using
FLUSH LOGS
,
which causes the server to rename the error log with an
-old
suffix and open a new error log.
The general query log should be protected because logged statements might contain passwords. See
Section 6.1.2.3, “Passwords and Logging”
.
5.2.3. The Binary Log
The binary log contains “events” that describe database changes such as table creation operations or
changes to table data. It also contains events for statements that potentially could have made changes
(for example, a
DELETE
which matched no rows). The binary log also contains information about how
long each statement took that updated data. The binary log has two important purposes:
• For replication, the binary log on a master replication server provides a record of the data changes to
be sent to slave servers. The master server sends the events contained in its binary log to its slaves,
which execute those events to make the same data changes that were made on the master. See
Section 16.2, “Replication Implementation”
.
• Certain data recovery operations require use of the binary log. After a backup has been restored,
the events in the binary log that were recorded after the backup was made are re-executed. These
events bring databases up to date from the point of the backup. See
Section 7.5, “Point-in-Time
(Incremental) Recovery Using the Binary Log”
.
Note
The binary log has replaced the old update log, which is no longer available as
of MySQL 5.0. The binary log contains all information that is available in the
update log in a more efficient format and in a manner that is transaction-safe.
If you are using transactions, you must use the MySQL binary log for backups
instead of the old update log.
The binary log is not used for statements such as
SELECT
or
SHOW
that do not modify data. To log all
statements (for example, to identify a problem query), use the general query log. See
Section 5.2.2,
“The General Query Log”
.
Running a server with binary logging enabled makes performance slightly slower. However, the
benefits of the binary log in enabling you to set up replication and for restore operations generally
outweigh this minor performance decrement.
The binary log should be protected because logged statements might contain passwords. See
Section 6.1.2.3, “Passwords and Logging”
.
The following discussion describes some of the server options and variables that affect the operation of
binary logging. For a complete list, see
Section 16.1.2.4, “Binary Log Options and Variables”
.
For detailed information about the format of the binary log, see
MySQL Internals: The Binary Log
.
To enable the binary log, start the server with the
--log-bin[=base_name]
[1467]
option. If no
base_name
value is given, the default name is the value of the
pid-file
option (which by default is
the name of host machine) followed by
-bin
. If the basename is given, the server writes the file in the
data directory unless the basename is given with a leading absolute path name to specify a different
directory. It is recommended that you specify a basename explicitly rather than using the default of the
host name; see
Section C.5.8, “Known Issues in MySQL”
, for the reason.
Note
From MySQL 5.0.41 through 5.0.52, “mysql” was used when no
base_name
was specified. Also in these versions, a path given as part of the
--log-
Содержание 5.0
Страница 1: ...MySQL 5 0 Reference Manual ...
Страница 18: ...xviii ...
Страница 60: ...40 ...
Страница 396: ...376 ...
Страница 578: ...558 ...
Страница 636: ...616 ...
Страница 844: ...824 ...
Страница 1234: ...1214 ...
Страница 1426: ...MySQL Proxy Scripting 1406 The following diagram shows an overview of the classes exposed by MySQL Proxy ...
Страница 1427: ...MySQL Proxy Scripting 1407 ...
Страница 1734: ...1714 ...
Страница 1752: ...1732 ...
Страница 1783: ...Configuring Connector ODBC 1763 ...
Страница 1793: ...Connector ODBC Examples 1773 ...
Страница 1839: ...Connector Net Installation 1819 2 You must choose the type of installation to perform ...
Страница 1842: ...Connector Net Installation 1822 5 Once the installation has been completed click Finish to exit the installer ...
Страница 1864: ...Connector Net Visual Studio Integration 1844 Figure 20 24 Debug Stepping Figure 20 25 Function Stepping 1 of 2 ...
Страница 2850: ...2830 ...
Страница 2854: ...2834 ...
Страница 2928: ...2908 ...
Страница 3000: ...2980 ...
Страница 3122: ...3102 ...
Страница 3126: ...3106 ...
Страница 3174: ...3154 ...
Страница 3232: ...3212 ...