1
.\" Title: \fBmysqlcheck\fR
3
.\" Generator: DocBook XSL Stylesheets v1.70.1 <http://docbook.sf.net/>
5
.\" Manual: MySQL Database System
8
.TH "\fBMYSQLCHECK\fR" "1" "05/23/2009" "MySQL 6.0" "MySQL Database System"
9
.\" disable hyphenation
11
.\" disable justification (adjust text to left margin only)
14
mysqlcheck \- a table maintenance program
17
\fBmysqlcheck [\fR\fB\fIoptions\fR\fR\fB] [\fR\fB\fIdb_name\fR\fR\fB [\fR\fB\fItbl_name\fR\fR\fB ...]]\fR
22
client performs table maintenance: It checks, repairs, optimizes, or analyzes tables.
24
Each table is locked and therefore unavailable to other sessions while it is being processed. Table maintenance operations can be time\-consuming, particularly for large tables. If you use the
27
\fB\-\-all\-databases\fR
28
option to process all tables in one or more databases, an invocation of
30
might take a long time. (This is also true for
32
because that program invokes
34
to check all tables and repair them if necessary.)
37
is similar in function to
38
\fBmyisamchk\fR, but works differently. The main operational difference is that
42
server is running, whereas
44
should be used when it is not. The benefit of using
46
is that you do not have to stop the server to perform table maintenance.
49
uses the SQL statements
54
in a convenient way for the user. It determines which statements to use for the operation you want to perform, and then sends the statements to the server to be executed. For details about which storage engines each statement works with, see the descriptions for those statements in
55
Section\ 12.5.2, \(lqTable Maintenance Statements\(rq.
59
storage engine supports all four maintenance operations, so
61
can be used to perform any of them on
63
tables. Other storage engines do not necessarily support all operations. In such cases, an error message is displayed. For example, if
67
table, an attempt to check it produces this result:
71
shell> \fBmysqlcheck test t\fR
73
note : The storage engine for the table doesn't support check
79
is unable to repair a table, see
80
Section\ 2.11.4, \(lqRebuilding or Repairing Tables or Indexes\(rq
81
for manual table repair strategies. This will be the case, for example, for
83
tables, which can be checked with
84
CHECK TABLE, but not repaired with
89
with partitioned tables is not supported before MySQL 6.0.6.
92
.nr an-no-space-flag 1
97
It is best to make a backup of a table before performing a table repair operation; under some circumstances the operation might cause data loss. Possible causes include but are not limited to file system errors.
99
There are three general ways to invoke
104
shell> \fBmysqlcheck [\fR\fB\fIoptions\fR\fR\fB] \fR\fB\fIdb_name\fR\fR\fB [\fR\fB\fItables\fR\fR\fB]\fR
105
shell> \fBmysqlcheck [\fR\fB\fIoptions\fR\fR\fB] \-\-databases \fR\fB\fIdb_name1\fR\fR\fB [\fR\fB\fIdb_name2\fR\fR\fB \fR\fB\fIdb_name3\fR\fR\fB...]\fR
106
shell> \fBmysqlcheck [\fR\fB\fIoptions\fR\fR\fB] \-\-all\-databases\fR
110
If you do not name any tables following
115
\fB\-\-all\-databases\fR
116
option, entire databases are checked.
119
has a special feature compared to other client programs. The default behavior of checking tables (\fB\-\-check\fR) can be changed by renaming the binary. If you want to have a tool that repairs tables by default, you should just make a copy of
122
\fBmysqlrepair\fR, or make a symbolic link to
125
\fBmysqlrepair\fR. If you invoke
126
\fBmysqlrepair\fR, it repairs tables.
128
The following names can be used to change
139
The default option is \fB\-\-repair\fR
144
The default option is \fB\-\-analyze\fR
149
The default option is \fB\-\-optimize\fR
155
supports the options in the following list. It also reads option files and supports the options for processing them described at
156
Section\ 4.2.3.2.1, \(lqCommand\-Line Options that Affect Option\-File Handling\(rq.
162
Display a help message and exit.
165
\fB\-\-all\-databases\fR,
168
Check all tables in all databases. This is the same as using the
170
option and naming all the databases on the command line.
173
\fB\-\-all\-in\-1\fR,
176
Instead of issuing a statement for each table, execute a single statement for each database that names all the tables from that database to be processed.
185
\fB\-\-auto\-repair\fR
187
If a checked table is corrupted, automatically fix it. Any necessary repairs are done after all tables have been checked.
190
\fB\-\-character\-sets\-dir=\fR\fB\fIpath\fR\fR
192
The directory where character sets are installed. See
193
Section\ 9.2, \(lqThe Character Set Used for Data and Sorting\(rq.
199
Check the tables for errors. This is the default operation.
202
\fB\-\-check\-only\-changed\fR,
205
Check only tables that have changed since the last check or that have not been closed properly.
208
\fB\-\-check\-upgrade\fR,
215
option to check tables for incompatibilities with the current version of the server. This option automatically enables the
216
\fB\-\-fix\-db\-names\fR
218
\fB\-\-fix\-table\-names\fR
224
Compress all information sent between the client and the server if both support compression.
230
Process all tables in the named databases. Normally,
232
treats the first name argument on the command line as a database name and following names as table names. With this option, it treats all name arguments as database names.
235
\fB\-\-debug[=\fR\fB\fIdebug_options\fR\fR\fB]\fR,
236
\fB\-# [\fR\fB\fIdebug_options\fR\fR\fB]\fR
238
Write a debugging log. A typical
241
\'d:t:o,\fIfile_name\fR'. The default is
245
\fB\-\-debug\-check\fR
247
Print some debugging information when the program exits.
250
\fB\-\-debug\-info\fR
252
Print debugging information and memory and CPU usage statistics when the program exits.
255
\fB\-\-default\-character\-set=\fR\fB\fIcharset_name\fR\fR
259
as the default character set. See
260
Section\ 9.2, \(lqThe Character Set Used for Data and Sorting\(rq.
266
If you are using this option to check tables, it ensures that they are 100% consistent but takes a long time.
268
If you are using this option to repair tables, it runs an extended repair that may not only take a long time to execute, but may produce a lot of garbage rows also!
274
Check only tables that have not been closed properly.
277
\fB\-\-fix\-db\-names\fR
279
Convert database names to 5.1 format. Only database names that contain special characters are affected.
282
\fB\-\-fix\-table\-names\fR
284
Convert table names to 5.1 format. Only table names that contain special characters are affected. As of MySQL 6.0.5, this option also applies to views.
290
Continue even if an SQL error occurs.
293
\fB\-\-host=\fR\fB\fIhost_name\fR\fR,
294
\fB\-h \fR\fB\fIhost_name\fR\fR
296
Connect to the MySQL server on the given host.
299
\fB\-\-medium\-check\fR,
302
Do a check that is faster than an
304
operation. This finds only 99.99% of all errors, which should be good enough in most cases.
313
\fB\-\-password[=\fR\fB\fIpassword\fR\fR\fB]\fR,
314
\fB\-p[\fR\fB\fIpassword\fR\fR\fB]\fR
316
The password to use when connecting to the server. If you use the short option form (\fB\-p\fR), you
318
have a space between the option and the password. If you omit the
324
option on the command line, you are prompted for one.
326
Specifying a password on the command line should be considered insecure. See
327
Section\ 5.5.6.2, \(lqEnd\-User Guidelines for Password Security\(rq.
333
On Windows, connect to the server via a named pipe. This option applies only for connections to a local server, and only if the server supports named\-pipe connections.
336
\fB\-\-port=\fR\fB\fIport_num\fR\fR,
337
\fB\-P \fR\fB\fIport_num\fR\fR
339
The TCP/IP port number to use for the connection.
342
\fB\-\-protocol={TCP|SOCKET|PIPE|MEMORY}\fR
344
The connection protocol to use for connecting to the server. It is useful when the other connection parameters normally would cause a protocol to be used other than the one you want. For details on the allowable values, see
345
Section\ 4.2.2, \(lqConnecting to the MySQL Server\(rq.
351
If you are using this option to check tables, it prevents the check from scanning the rows to check for incorrect links. This is the fastest check method.
353
If you are using this option to repair tables, it tries to repair only the index tree. This is the fastest repair method.
359
Perform a repair that can fix almost anything except unique keys that are not unique.
365
Silent mode. Print only error messages.
368
\fB\-\-socket=\fR\fB\fIpath\fR\fR,
369
\fB\-S \fR\fB\fIpath\fR\fR
372
localhost, the Unix socket file to use, or, on Windows, the name of the named pipe to use.
377
Options that begin with
379
specify whether to connect to the server via SSL and indicate where to find SSL keys and certificates. See
380
Section\ 5.5.7.3, \(lqSSL Command Options\(rq.
389
option. All name arguments following the option are regarded as table names.
394
For repair operations on
396
tables, get the table structure from the
398
file so that the table can be repaired even if the
403
\fB\-\-user=\fR\fB\fIuser_name\fR\fR,
404
\fB\-u \fR\fB\fIuser_name\fR\fR
406
The MySQL user name to use when connecting to the server.
412
Verbose mode. Print information about the various stages of program operation.
418
Display version information and exit.
421
Copyright 2007\-2008 MySQL AB, 2009 Sun Microsystems, Inc.
423
This documentation is free software; you can redistribute it and/or modify it only under the terms of the GNU General Public License as published by the Free Software Foundation; version 2 of the License.
425
This documentation is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
427
You should have received a copy of the GNU General Public License along with the program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110\-1301 USA or see http://www.gnu.org/licenses/.
429
For more information, please refer to the MySQL Reference Manual,
430
which may already be installed locally and which is also available
431
online at http://dev.mysql.com/doc/.
433
Sun Microsystems, Inc. (http://www.mysql.com/).