myisamchk
— MyISAM Table-Maintenance Utility
318
shell>
myisamchk [options] tbl_name ...
The
options
specify what you want
myisamchk
to do. They are described in the following sections.
You can also get a list of options by invoking
myisamchk --help
.
With no options,
myisamchk
simply checks your table as the default operation. To get more
information or to tell
myisamchk
to take corrective action, specify options as described in the following
discussion.
tbl_name
is the database table you want to check or repair. If you run
myisamchk
somewhere
other than in the database directory, you must specify the path to the database directory, because
myisamchk
has no idea where the database is located. In fact,
myisamchk
does not actually care
whether the files you are working on are located in a database directory. You can copy the files that
correspond to a database table into some other location and perform recovery operations on them
there.
You can name several tables on the
myisamchk
command line if you wish. You can also specify a
table by naming its index file (the file with the
.MYI
suffix). This enables you to specify all tables in a
directory by using the pattern
*.MYI
. For example, if you are in a database directory, you can check all
the
MyISAM
tables in that directory like this:
shell>
myisamchk *.MYI
If you are not in the database directory, you can check all the tables there by specifying the path to the
directory:
shell>
myisamchk /path/to/database_dir/*.MYI
You can even check all tables in all databases by specifying a wildcard with the path to the MySQL
data directory:
shell>
myisamchk /path/to/datadir/*/*.MYI
The recommended way to quickly check all
MyISAM
tables is:
shell>
myisamchk --silent --fast /path/to/datadir/*/*.MYI
If you want to check all
MyISAM
tables and repair any that are corrupted, you can use the following
command:
shell>
myisamchk --silent --force --fast --update-state \
--key_buffer_size=64M --sort_buffer_size=64M \
--read_buffer_size=1M --write_buffer_size=1M \
/path/to/datadir/*/*.MYI
This command assumes that you have more than 64MB free. For more information about memory
allocation with
myisamchk
, see
Section 4.6.3.6, “
myisamchk
Memory Usage”
.
For additional information about using
myisamchk
, see
Section 7.6, “
MyISAM
Table Maintenance and
Crash Recovery”
.
Important
You must ensure that no other program is using the tables while you are
running
myisamchk
. The most effective means of doing so is to shut down the
MySQL server while running
myisamchk
, or to lock all tables that
myisamchk
is being used on.
Otherwise, when you run
myisamchk
, it may display the following error
message:
warning: clients are using or haven't closed the table properly
This means that you are trying to check a table that has been updated by
another program (such as the
mysqld
server) that hasn't yet closed the file or
Summary of Contents for 5.0
Page 1: ...MySQL 5 0 Reference Manual ...
Page 18: ...xviii ...
Page 60: ...40 ...
Page 396: ...376 ...
Page 578: ...558 ...
Page 636: ...616 ...
Page 844: ...824 ...
Page 1234: ...1214 ...
Page 1427: ...MySQL Proxy Scripting 1407 ...
Page 1734: ...1714 ...
Page 1752: ...1732 ...
Page 1783: ...Configuring Connector ODBC 1763 ...
Page 1793: ...Connector ODBC Examples 1773 ...
Page 1839: ...Connector Net Installation 1819 2 You must choose the type of installation to perform ...
Page 2850: ...2830 ...
Page 2854: ...2834 ...
Page 2928: ...2908 ...
Page 3000: ...2980 ...
Page 3122: ...3102 ...
Page 3126: ...3106 ...
Page 3174: ...3154 ...
Page 3232: ...3212 ...