1MYSQLCHECK(1)                MySQL Database System               MYSQLCHECK(1)
2
3
4

NAME

6       mysqlcheck - a table maintenance program
7

SYNOPSIS

9       mysqlcheck [options] [db_name [tbl_name ...]]
10

DESCRIPTION

12       The mysqlcheck client performs table maintenance: It checks, repairs,
13       optimizes, or analyzes tables.
14
15       Each table is locked and therefore unavailable to other sessions while
16       it is being processed, although for check operations, the table is
17       locked with a READ lock only (see Section 13.3.5, “LOCK TABLES and
18       UNLOCK TABLES Syntax”, for more information about READ and WRITE
19       locks). Table maintenance operations can be time-consuming,
20       particularly for large tables. If you use the --databases or
21       --all-databases option to process all tables in one or more databases,
22       an invocation of mysqlcheck might take a long time. (This is also true
23       for mysql_upgrade because that program invokes mysqlcheck to check all
24       tables and repair them if necessary.)
25
26       mysqlcheck is similar in function to myisamchk, but works differently.
27       The main operational difference is that mysqlcheck must be used when
28       the mysqld server is running, whereas myisamchk should be used when it
29       is not. The benefit of using mysqlcheck is that you do not have to stop
30       the server to perform table maintenance.
31
32       mysqlcheck uses the SQL statements CHECK TABLE, REPAIR TABLE, ANALYZE
33       TABLE, and OPTIMIZE TABLE in a convenient way for the user. It
34       determines which statements to use for the operation you want to
35       perform, and then sends the statements to the server to be executed.
36       For details about which storage engines each statement works with, see
37       the descriptions for those statements in Section 13.7.2, “Table
38       Maintenance Statements”.
39
40       The MyISAM storage engine supports all four maintenance operations, so
41       mysqlcheck can be used to perform any of them on MyISAM tables. Other
42       storage engines do not necessarily support all operations. In such
43       cases, an error message is displayed. For example, if test.t is a
44       MEMORY table, an attempt to check it produces this result:
45
46           shell> mysqlcheck test t
47           test.t
48           note     : The storage engine for the table doesn't support check
49
50       If mysqlcheck is unable to repair a table, see Section 2.13.4,
51       “Rebuilding or Repairing Tables or Indexes” for manual table repair
52       strategies. This will be the case, for example, for InnoDB tables,
53       which can be checked with CHECK TABLE, but not repaired with REPAIR
54       TABLE.
55
56       The use of mysqlcheck with partitioned tables is not supported before
57       MySQL 5.1.27.
58
59           Caution
60           It is best to make a backup of a table before performing a table
61           repair operation; under some circumstances the operation might
62           cause data loss. Possible causes include but are not limited to
63           file system errors.
64
65       There are three general ways to invoke mysqlcheck:
66
67           shell> mysqlcheck [options] db_name [tbl_name ...]
68           shell> mysqlcheck [options] --databases db_name ...
69           shell> mysqlcheck [options] --all-databases
70
71       If you do not name any tables following db_name or if you use the
72       --databases or --all-databases option, entire databases are checked.
73
74       mysqlcheck has a special feature compared to other client programs. The
75       default behavior of checking tables (--check) can be changed by
76       renaming the binary. If you want to have a tool that repairs tables by
77       default, you should just make a copy of mysqlcheck named mysqlrepair,
78       or make a symbolic link to mysqlcheck named mysqlrepair. If you invoke
79       mysqlrepair, it repairs tables.
80
81       The names shown in the following table can be used to change mysqlcheck
82       default behavior.
83
84       ┌──────────────┬───────────────────────┐
85Command       Meaning               
86       ├──────────────┼───────────────────────┤
87mysqlrepair   │ The default option is │
88       │              │ --repair              
89       ├──────────────┼───────────────────────┤
90mysqlanalyze  │ The default option is │
91       │              │ --analyze             
92       ├──────────────┼───────────────────────┤
93mysqloptimize │ The default option is │
94       │              │ --optimize            
95       └──────────────┴───────────────────────┘
96
97       mysqlcheck supports the following options, which can be specified on
98       the command line or in the [mysqlcheck] and [client] groups of an
99       option file.  mysqlcheck also supports the options for processing
100       option files described at Section 4.2.3.4, “Command-Line Options that
101       Affect Option-File Handling”.
102
103       ·   --help, -?
104
105           Display a help message and exit.
106
107       ·   --all-databases, -A
108
109           Check all tables in all databases. This is the same as using the
110           --databases option and naming all the databases on the command
111           line.
112
113       ·   --all-in-1, -1
114
115           Instead of issuing a statement for each table, execute a single
116           statement for each database that names all the tables from that
117           database to be processed.
118
119       ·   --analyze, -a
120
121           Analyze the tables.
122
123       ·   --auto-repair
124
125           If a checked table is corrupted, automatically fix it. Any
126           necessary repairs are done after all tables have been checked.
127
128       ·   --bind-address=ip_address
129
130           On a computer having multiple network interfaces, this option can
131           be used to select which interface is employed when connecting to
132           the MySQL server.
133
134           This option is supported only in the version of mysqlcheck that is
135           supplied with MySQL Cluster, beginning with MySQL Cluster NDB
136           6.3.4. It is not available in standard MySQL 5.1 releases.
137
138       ·   --character-sets-dir=path
139
140           The directory where character sets are installed. See Section 10.5,
141           “Character Set Configuration”.
142
143       ·   --check, -c
144
145           Check the tables for errors. This is the default operation.
146
147       ·   --check-only-changed, -C
148
149           Check only tables that have changed since the last check or that
150           have not been closed properly.
151
152       ·   --check-upgrade, -g
153
154           Invoke CHECK TABLE with the FOR UPGRADE option to check tables for
155           incompatibilities with the current version of the server. This
156           option automatically enables the --fix-db-names and
157           --fix-table-names options.  --check-upgrade was added in MySQL
158           5.1.7.
159
160       ·   --compress
161
162           Compress all information sent between the client and the server if
163           both support compression.
164
165       ·   --databases, -B
166
167           Process all tables in the named databases. Normally, mysqlcheck
168           treats the first name argument on the command line as a database
169           name and following names as table names. With this option, it
170           treats all name arguments as database names.
171
172       ·   --debug[=debug_options], -# [debug_options]
173
174           Write a debugging log. A typical debug_options string is
175           'd:t:o,file_name'. The default is 'd:t:o'.
176
177       ·   --debug-check
178
179           Print some debugging information when the program exits. This
180           option was added in MySQL 5.1.21.
181
182       ·   --debug-info
183
184           Print debugging information and memory and CPU usage statistics
185           when the program exits. This option was added in MySQL 5.1.14.
186
187       ·   --default-character-set=charset_name
188
189           Use charset_name as the default character set. See Section 10.5,
190           “Character Set Configuration”.
191
192       ·   --extended, -e
193
194           If you are using this option to check tables, it ensures that they
195           are 100% consistent but takes a long time.
196
197           If you are using this option to repair tables, it runs an extended
198           repair that may not only take a long time to execute, but may
199           produce a lot of garbage rows also!
200
201       ·   --fast, -F
202
203           Check only tables that have not been closed properly.
204
205       ·   --fix-db-names
206
207           Convert database names to 5.1 format. Only database names that
208           contain special characters are affected. This option was added in
209           MySQL 5.1.7.
210
211       ·   --fix-table-names
212
213           Convert table names to 5.1 format. Only table names that contain
214           special characters are affected. This option was added in MySQL
215           5.1.7. As of MySQL 5.1.23, this option also applies to views.
216
217       ·   --force, -f
218
219           Continue even if an SQL error occurs.
220
221       ·   --host=host_name, -h host_name
222
223           Connect to the MySQL server on the given host.
224
225       ·   --medium-check, -m
226
227           Do a check that is faster than an --extended operation. This finds
228           only 99.99% of all errors, which should be good enough in most
229           cases.
230
231       ·   --optimize, -o
232
233           Optimize the tables.
234
235       ·   --password[=password], -p[password]
236
237           The password to use when connecting to the server. If you use the
238           short option form (-p), you cannot have a space between the option
239           and the password. If you omit the password value following the
240           --password or -p option on the command line, mysqlcheck prompts for
241           one.
242
243           Specifying a password on the command line should be considered
244           insecure. See Section 6.1.2.1, “End-User Guidelines for Password
245           Security”. You can use an option file to avoid giving the password
246           on the command line.
247
248       ·   --pipe, -W
249
250           On Windows, connect to the server using a named pipe. This option
251           applies only if the server supports named-pipe connections.
252
253       ·   --port=port_num, -P port_num
254
255           The TCP/IP port number to use for the connection.
256
257       ·   --protocol={TCP|SOCKET|PIPE|MEMORY}
258
259           The connection protocol to use for connecting to the server. It is
260           useful when the other connection parameters normally would cause a
261           protocol to be used other than the one you want. For details on the
262           permissible values, see Section 4.2.2, “Connecting to the MySQL
263           Server”.
264
265       ·   --quick, -q
266
267           If you are using this option to check tables, it prevents the check
268           from scanning the rows to check for incorrect links. This is the
269           fastest check method.
270
271           If you are using this option to repair tables, it tries to repair
272           only the index tree. This is the fastest repair method.
273
274       ·   --repair, -r
275
276           Perform a repair that can fix almost anything except unique keys
277           that are not unique.
278
279       ·   --silent, -s
280
281           Silent mode. Print only error messages.
282
283       ·   --socket=path, -S path
284
285           For connections to localhost, the Unix socket file to use, or, on
286           Windows, the name of the named pipe to use.
287
288       ·   --ssl*
289
290           Options that begin with --ssl specify whether to connect to the
291           server using SSL and indicate where to find SSL keys and
292           certificates. See Section 6.3.6.4, “SSL Command Options”.
293
294       ·   --tables
295
296           Override the --databases or -B option. All name arguments following
297           the option are regarded as table names.
298
299       ·   --use-frm
300
301           For repair operations on MyISAM tables, get the table structure
302           from the .frm file so that the table can be repaired even if the
303           .MYI header is corrupted.
304
305       ·   --user=user_name, -u user_name
306
307           The MySQL user name to use when connecting to the server.
308
309       ·   --verbose, -v
310
311           Verbose mode. Print information about the various stages of program
312           operation.
313
314       ·   --version, -V
315
316           Display version information and exit.
317
318       ·   --write-binlog
319
320           This option is enabled by default, so that ANALYZE TABLE, OPTIMIZE
321           TABLE, and REPAIR TABLE statements generated by mysqlcheck are
322           written to the binary log. Use --skip-write-binlog to cause
323           NO_WRITE_TO_BINLOG to be added to the statements so that they are
324           not logged. Use the --skip-write-binlog when these statements
325           should not be sent to replication slaves or run when using the
326           binary logs for recovery from backup. This option was added in
327           MySQL 5.1.18.
328
330       Copyright © 1997, 2013, Oracle and/or its affiliates. All rights
331       reserved.
332
333       This documentation is free software; you can redistribute it and/or
334       modify it only under the terms of the GNU General Public License as
335       published by the Free Software Foundation; version 2 of the License.
336
337       This documentation is distributed in the hope that it will be useful,
338       but WITHOUT ANY WARRANTY; without even the implied warranty of
339       MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
340       General Public License for more details.
341
342       You should have received a copy of the GNU General Public License along
343       with the program; if not, write to the Free Software Foundation, Inc.,
344       51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA or see
345       http://www.gnu.org/licenses/.
346
347

SEE ALSO

349       For more information, please refer to the MySQL Reference Manual, which
350       may already be installed locally and which is also available online at
351       http://dev.mysql.com/doc/.
352

AUTHOR

354       Oracle Corporation (http://dev.mysql.com/).
355
356
357
358MySQL 5.1                         11/04/2013                     MYSQLCHECK(1)
Impressum