positions may enable you to be more precise about which part of the log to recover, especially if many
transactions occurred around the same time as a damaging SQL statement. To determine the position
numbers, run
executed, but redirect the results to a text file for examination. This can be done like so:
shell>
mysqlbinlog --start-datetime="2005-04-20 9:55:00" \
--stop-datetime="2005-04-20 10:05:00" \
/var/log/mysql/bin.123456 > /tmp/mysql_restore.sql
This command creates a small text file in the
the time that the deleterious SQL statement was executed. Open this file with a text editor and look
for the statement that you do not want to repeat. Determine the positions in the binary log for stopping
and resuming the recovery and make note of them. Positions are labeled as
number. After restoring the previous backup file, use the position numbers to process the binary log
file. For example, you would use commands something like these:
shell>
mysqlbinlog --stop-position=368312 /var/log/mysql/bin.123456 \
| mysql -u root -p
shell>
mysqlbinlog --start-position=368315 /var/log/mysql/bin.123456 \
| mysql -u root -p
The first command recovers all the transactions up until the stop position given. The second command
recovers all transactions from the starting position given until the end of the binary log. Because the
output of
mysqlbinlog
the recovered data and related MySQL logs will reflect the original times at which the transactions were
executed.
7.6.
Table Maintenance and Crash Recovery
MyISAM
This section discusses how to use
and
.MYD
.MYI
Section 4.6.3,
be found at
Section 2.19.4, "Rebuilding or Repairing Tables or
You can use
how to perform these operations and how to set up a table maintenance schedule. For information
about using
Information with
Even though table repair with
before doing a repair or any maintenance operation that could make a lot of changes to a table.
myisamchk
parameters that are incompatible with the values used by the MySQL server. To avoid this problem,
follow the guidelines in
table maintenance can also be done using the SQL statements that perform operations similar
MyISAM
to what
myisamchk
• To check
• To repair
MyISAM
• To optimize
• To analyze
For additional information about these statements, see
Statements".
These statements can be used directly or by means of the
advantage of these statements over
Table Maintenance and Crash Recovery
MyISAM
for a range of times near the time when the unwanted transaction was
mysqlbinlog
includes
SET TIMESTAMP
myisamchk
files for storing data and indexes). For general
"myisamchk
— MyISAM Table-Maintenance
to check, repair, or optimize database tables. The following sections describe
myisamchk
to get information about your tables, see
myisamchk
myisamchk".
myisamchk
operations that affect indexes can cause
Section 4.6.3.1,
can do:
tables, use
MyISAM
CHECK
tables, use
REPAIR
tables, use
MyISAM
OPTIMIZE
tables, use
MyISAM
ANALYZE
directory that contains the SQL statements around
/tmp
statements before each SQL statement recorded,
to check or repair
is quite secure, it is always a good idea to make a backup
FULLTEXT
"myisamchk
General
TABLE.
TABLE.
TABLE.
TABLE.
Section 13.7.2, "Table Maintenance
mysqlcheck
is that the server does all the work. With myisamchk,
myisamchk
633
log_pos
tables (tables that have
MyISAM
background, see
myisamchk
Utility". Other table-repair information can
Indexes".
Section 4.6.3.5, "Obtaining Table
indexes to be rebuilt with full-text
Options".
client program. One
followed by a
Need help?
Do you have a question about the 5.0 and is the answer not in the manual?
Questions and answers