1MYSQLCHECK(1) MySQL Database System MYSQLCHECK(1)
2
3
4
6 mysqlcheck - a table maintenance program
7
9 mysqlcheck [options] [db_name [tbl_name ...]]
10
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.6, “LOCK TABLES and
18 UNLOCK TABLES Statements”, 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 the MySQL upgrade procedure if it determines that table checking is
24 needed because it processes tables the same way.)
25
26 mysqlcheck must be used when the mysqld server is running, which means
27 that you do not have to stop the server to perform table maintenance.
28
29 mysqlcheck uses the SQL statements CHECK TABLE, REPAIR TABLE, ANALYZE
30 TABLE, and OPTIMIZE TABLE in a convenient way for the user. It
31 determines which statements to use for the operation you want to
32 perform, and then sends the statements to the server to be executed.
33 For details about which storage engines each statement works with, see
34 the descriptions for those statements in Section 13.7.3, “Table
35 Maintenance Statements”.
36
37 All storage engines do not necessarily support all four maintenance
38 operations. In such cases, an error message is displayed. For example,
39 if test.t is an MEMORY table, an attempt to check it produces this
40 result:
41
42 shell> mysqlcheck test t
43 test.t
44 note : The storage engine for the table doesn't support check
45
46 If mysqlcheck is unable to repair a table, see Section 2.11.13,
47 “Rebuilding or Repairing Tables or Indexes” for manual table repair
48 strategies. This will be the case, for example, for InnoDB tables,
49 which can be checked with CHECK TABLE, but not repaired with REPAIR
50 TABLE.
51
52 Caution
53 It is best to make a backup of a table before performing a table
54 repair operation; under some circumstances the operation might
55 cause data loss. Possible causes include but are not limited to
56 file system errors.
57
58 There are three general ways to invoke mysqlcheck:
59
60 shell> mysqlcheck [options] db_name [tbl_name ...]
61 shell> mysqlcheck [options] --databases db_name ...
62 shell> mysqlcheck [options] --all-databases
63
64 If you do not name any tables following db_name or if you use the
65 --databases or --all-databases option, entire databases are checked.
66
67 mysqlcheck has a special feature compared to other client programs. The
68 default behavior of checking tables (--check) can be changed by
69 renaming the binary. If you want to have a tool that repairs tables by
70 default, you should just make a copy of mysqlcheck named mysqlrepair,
71 or make a symbolic link to mysqlcheck named mysqlrepair. If you invoke
72 mysqlrepair, it repairs tables.
73
74 The names shown in the following table can be used to change mysqlcheck
75 default behavior.
76
77 ┌──────────────┬───────────────────────┐
78 │Command │ Meaning │
79 ├──────────────┼───────────────────────┤
80 │mysqlrepair │ The default option is │
81 │ │ --repair │
82 ├──────────────┼───────────────────────┤
83 │mysqlanalyze │ The default option is │
84 │ │ --analyze │
85 ├──────────────┼───────────────────────┤
86 │mysqloptimize │ The default option is │
87 │ │ --optimize │
88 └──────────────┴───────────────────────┘
89
90 mysqlcheck supports the following options, which can be specified on
91 the command line or in the [mysqlcheck] and [client] groups of an
92 option file. For information about option files used by MySQL programs,
93 see Section 4.2.2.2, “Using Option Files”.
94
95 · --help, -?
96
97 Display a help message and exit.
98
99 · --all-databases, -A
100
101 Check all tables in all databases. This is the same as using the
102 --databases option and naming all the databases on the command
103 line, except that the INFORMATION_SCHEMA and performance_schema
104 databases are not checked. They can be checked by explicitly naming
105 them with the --databases option.
106
107 · --all-in-1, -1
108
109 Instead of issuing a statement for each table, execute a single
110 statement for each database that names all the tables from that
111 database to be processed.
112
113 · --analyze, -a
114
115 Analyze the tables.
116
117 · --auto-repair
118
119 If a checked table is corrupted, automatically fix it. Any
120 necessary repairs are done after all tables have been checked.
121
122 · --bind-address=ip_address
123
124 On a computer having multiple network interfaces, use this option
125 to select which interface to use for connecting to the MySQL
126 server.
127
128 · --character-sets-dir=dir_name
129
130 The directory where character sets are installed. See
131 Section 10.15, “Character Set Configuration”.
132
133 · --check, -c
134
135 Check the tables for errors. This is the default operation.
136
137 · --check-only-changed, -C
138
139 Check only tables that have changed since the last check or that
140 have not been closed properly.
141
142 · --check-upgrade, -g
143
144 Invoke CHECK TABLE with the FOR UPGRADE option to check tables for
145 incompatibilities with the current version of the server.
146
147 · --compress
148
149 Compress all information sent between the client and the server if
150 possible. See Section 4.2.6, “Connection Compression Control”.
151
152 As of MySQL 8.0.18, this option is deprecated. It will be removed
153 in a future MySQL version. See the section called “Legacy
154 Connection Compression Configuration”.
155
156 · --compression-algorithms=value The permitted compression algorithms
157 for connections to the server. The available algorithms are the
158 same as for the protocol_compression_algorithms system variable.
159 The default value is uncompressed.
160
161 For more information, see Section 4.2.6, “Connection Compression
162 Control”.
163
164 This option was added in MySQL 8.0.18.
165
166 · --databases, -B
167
168 Process all tables in the named databases. Normally, mysqlcheck
169 treats the first name argument on the command line as a database
170 name and any following names as table names. With this option, it
171 treats all name arguments as database names.
172
173 · --debug[=debug_options], -# [debug_options]
174
175 Write a debugging log. A typical debug_options string is
176 d:t:o,file_name. The default is d:t:o.
177
178 This option is available only if MySQL was built using WITH_DEBUG.
179 MySQL release binaries provided by Oracle are not built using this
180 option.
181
182 · --debug-check
183
184 Print some debugging information when the program exits.
185
186 This option is available only if MySQL was built using WITH_DEBUG.
187 MySQL release binaries provided by Oracle are not built using this
188 option.
189
190 · --debug-info
191
192 Print debugging information and memory and CPU usage statistics
193 when the program exits.
194
195 This option is available only if MySQL was built using WITH_DEBUG.
196 MySQL release binaries provided by Oracle are not built using this
197 option.
198
199 · --default-character-set=charset_name
200
201 Use charset_name as the default character set. See Section 10.15,
202 “Character Set Configuration”.
203
204 · --defaults-extra-file=file_name
205
206 Read this option file after the global option file but (on Unix)
207 before the user option file. If the file does not exist or is
208 otherwise inaccessible, an error occurs. file_name is interpreted
209 relative to the current directory if given as a relative path name
210 rather than a full path name.
211
212 For additional information about this and other option-file
213 options, see Section 4.2.2.3, “Command-Line Options that Affect
214 Option-File Handling”.
215
216 · --defaults-file=file_name
217
218 Use only the given option file. If the file does not exist or is
219 otherwise inaccessible, an error occurs. file_name is interpreted
220 relative to the current directory if given as a relative path name
221 rather than a full path name.
222
223 Exception: Even with --defaults-file, client programs read
224 .mylogin.cnf.
225
226 For additional information about this and other option-file
227 options, see Section 4.2.2.3, “Command-Line Options that Affect
228 Option-File Handling”.
229
230 · --defaults-group-suffix=str
231
232 Read not only the usual option groups, but also groups with the
233 usual names and a suffix of str. For example, mysqlcheck normally
234 reads the [client] and [mysqlcheck] groups. If the
235 --defaults-group-suffix=_other option is given, mysqlcheck also
236 reads the [client_other] and [mysqlcheck_other] groups.
237
238 For additional information about this and other option-file
239 options, see Section 4.2.2.3, “Command-Line Options that Affect
240 Option-File Handling”.
241
242 · --extended, -e
243
244 If you are using this option to check tables, it ensures that they
245 are 100% consistent but takes a long time.
246
247 If you are using this option to repair tables, it runs an extended
248 repair that may not only take a long time to execute, but may
249 produce a lot of garbage rows also!
250
251 · --default-auth=plugin
252
253 A hint about which client-side authentication plugin to use. See
254 Section 6.2.17, “Pluggable Authentication”.
255
256 · --enable-cleartext-plugin
257
258 Enable the mysql_clear_password cleartext authentication plugin.
259 (See Section 6.4.1.4, “Client-Side Cleartext Pluggable
260 Authentication”.)
261
262 · --fast, -F
263
264 Check only tables that have not been closed properly.
265
266 · --force, -f
267
268 Continue even if an SQL error occurs.
269
270 · --get-server-public-key
271
272 Request from the server the public key required for RSA key
273 pair-based password exchange. This option applies to clients that
274 authenticate with the caching_sha2_password authentication plugin.
275 For that plugin, the server does not send the public key unless
276 requested. This option is ignored for accounts that do not
277 authenticate with that plugin. It is also ignored if RSA-based
278 password exchange is not used, as is the case when the client
279 connects to the server using a secure connection.
280
281 If --server-public-key-path=file_name is given and specifies a
282 valid public key file, it takes precedence over
283 --get-server-public-key.
284
285 For information about the caching_sha2_password plugin, see
286 Section 6.4.1.2, “Caching SHA-2 Pluggable Authentication”.
287
288 · --host=host_name, -h host_name
289
290 Connect to the MySQL server on the given host.
291
292 · --login-path=name
293
294 Read options from the named login path in the .mylogin.cnf login
295 path file. A “login path” is an option group containing options
296 that specify which MySQL server to connect to and which account to
297 authenticate as. To create or modify a login path file, use the
298 mysql_config_editor utility. See mysql_config_editor(1).
299
300 For additional information about this and other option-file
301 options, see Section 4.2.2.3, “Command-Line Options that Affect
302 Option-File Handling”.
303
304 · --medium-check, -m
305
306 Do a check that is faster than an --extended operation. This finds
307 only 99.99% of all errors, which should be good enough in most
308 cases.
309
310 · --no-defaults
311
312 Do not read any option files. If program startup fails due to
313 reading unknown options from an option file, --no-defaults can be
314 used to prevent them from being read.
315
316 The exception is that the .mylogin.cnf file, if it exists, is read
317 in all cases. This permits passwords to be specified in a safer way
318 than on the command line even when --no-defaults is used.
319 (.mylogin.cnf is created by the mysql_config_editor utility. See
320 mysql_config_editor(1).)
321
322 For additional information about this and other option-file
323 options, see Section 4.2.2.3, “Command-Line Options that Affect
324 Option-File Handling”.
325
326 · --optimize, -o
327
328 Optimize the tables.
329
330 · --password[=password], -p[password]
331
332 The password of the MySQL account used for connecting to the
333 server. The password value is optional. If not given, mysqlcheck
334 prompts for one. If given, there must be no space between
335 --password= or -p and the password following it. If no password
336 option is specified, the default is to send no password.
337
338 Specifying a password on the command line should be considered
339 insecure. To avoid giving the password on the command line, use an
340 option file. See Section 6.1.2.1, “End-User Guidelines for Password
341 Security”.
342
343 To explicitly specify that there is no password and that mysqlcheck
344 should not prompt for one, use the --skip-password option.
345
346 · --pipe, -W
347
348 On Windows, connect to the server using a named pipe. This option
349 applies only if the server was started with the named_pipe system
350 variable enabled to support named-pipe connections. In addition,
351 the user making the connection must be a member of the Windows
352 group specified by the named_pipe_full_access_group system
353 variable.
354
355 · --plugin-dir=dir_name
356
357 The directory in which to look for plugins. Specify this option if
358 the --default-auth option is used to specify an authentication
359 plugin but mysqlcheck does not find it. See Section 6.2.17,
360 “Pluggable Authentication”.
361
362 · --port=port_num, -P port_num
363
364 For TCP/IP connections, the port number to use.
365
366 · --print-defaults
367
368 Print the program name and all options that it gets from option
369 files.
370
371 For additional information about this and other option-file
372 options, see Section 4.2.2.3, “Command-Line Options that Affect
373 Option-File Handling”.
374
375 · --protocol={TCP|SOCKET|PIPE|MEMORY}
376
377 The connection protocol to use for connecting to the server. It is
378 useful when the other connection parameters normally result in use
379 of a protocol other than the one you want. For details on the
380 permissible values, see Section 4.2.4, “Connecting to the MySQL
381 Server Using Command Options”.
382
383 · --quick, -q
384
385 If you are using this option to check tables, it prevents the check
386 from scanning the rows to check for incorrect links. This is the
387 fastest check method.
388
389 If you are using this option to repair tables, it tries to repair
390 only the index tree. This is the fastest repair method.
391
392 · --repair, -r
393
394 Perform a repair that can fix almost anything except unique keys
395 that are not unique.
396
397 · --server-public-key-path=file_name
398
399 The path name to a file containing a client-side copy of the public
400 key required by the server for RSA key pair-based password
401 exchange. The file must be in PEM format. This option applies to
402 clients that authenticate with the sha256_password or
403 caching_sha2_password authentication plugin. This option is ignored
404 for accounts that do not authenticate with one of those plugins. It
405 is also ignored if RSA-based password exchange is not used, as is
406 the case when the client connects to the server using a secure
407 connection.
408
409 If --server-public-key-path=file_name is given and specifies a
410 valid public key file, it takes precedence over
411 --get-server-public-key.
412
413 For sha256_password, this option applies only if MySQL was built
414 using OpenSSL.
415
416 For information about the sha256_password and caching_sha2_password
417 plugins, see Section 6.4.1.3, “SHA-256 Pluggable Authentication”,
418 and Section 6.4.1.2, “Caching SHA-2 Pluggable Authentication”.
419
420 · --shared-memory-base-name=name
421
422 On Windows, the shared-memory name to use for connections made
423 using shared memory to a local server. The default value is MYSQL.
424 The shared-memory name is case-sensitive.
425
426 This option applies only if the server was started with the
427 shared_memory system variable enabled to support shared-memory
428 connections.
429
430 · --silent, -s
431
432 Silent mode. Print only error messages.
433
434 · --skip-database=db_name
435
436 Do not include the named database (case-sensitive) in the
437 operations performed by mysqlcheck.
438
439 · --socket=path, -S path
440
441 For connections to localhost, the Unix socket file to use, or, on
442 Windows, the name of the named pipe to use.
443
444 On Windows, this option applies only if the server was started with
445 the named_pipe system variable enabled to support named-pipe
446 connections. In addition, the user making the connection must be a
447 member of the Windows group specified by the
448 named_pipe_full_access_group system variable.
449
450 · --ssl*
451
452 Options that begin with --ssl specify whether to connect to the
453 server using SSL and indicate where to find SSL keys and
454 certificates. See the section called “Command Options for Encrypted
455 Connections”.
456
457 · --ssl-fips-mode={OFF|ON|STRICT} Controls whether to enable FIPS
458 mode on the client side. The --ssl-fips-mode option differs from
459 other --ssl-xxx options in that it is not used to establish
460 encrypted connections, but rather to affect which cryptographic
461 operations are permitted. See Section 6.5, “FIPS Support”.
462
463 These --ssl-fips-mode values are permitted:
464
465 · OFF: Disable FIPS mode.
466
467 · ON: Enable FIPS mode.
468
469 · STRICT: Enable “strict” FIPS mode.
470
471
472 Note
473 If the OpenSSL FIPS Object Module is not available, the only
474 permitted value for --ssl-fips-mode is OFF. In this case,
475 setting --ssl-fips-mode to ON or STRICT causes the client to
476 produce a warning at startup and to operate in non-FIPS mode.
477
478 · --tables
479
480 Override the --databases or -B option. All name arguments following
481 the option are regarded as table names.
482
483 · --tls-ciphersuites=ciphersuite_list
484
485 The permissible ciphersuites for encrypted connections that use
486 TLSv1.3. The value is a list of one or more colon-separated
487 ciphersuite names. The ciphersuites that can be named for this
488 option depend on the SSL library used to compile MySQL. For
489 details, see Section 6.3.2, “Encrypted Connection TLS Protocols and
490 Ciphers”.
491
492 This option was added in MySQL 8.0.16.
493
494 · --tls-version=protocol_list
495
496 The permissible TLS protocols for encrypted connections. The value
497 is a list of one or more comma-separated protocol names. The
498 protocols that can be named for this option depend on the SSL
499 library used to compile MySQL. For details, see Section 6.3.2,
500 “Encrypted Connection TLS Protocols and Ciphers”.
501
502 · --use-frm
503
504 For repair operations on MyISAM tables, get the table structure
505 from the data dictionary so that the table can be repaired even if
506 the .MYI header is corrupted.
507
508 · --user=user_name, -u user_name
509
510 The user name of the MySQL account to use for connecting to the
511 server.
512
513 · --verbose, -v
514
515 Verbose mode. Print information about the various stages of program
516 operation.
517
518 · --version, -V
519
520 Display version information and exit.
521
522 · --write-binlog
523
524 This option is enabled by default, so that ANALYZE TABLE, OPTIMIZE
525 TABLE, and REPAIR TABLE statements generated by mysqlcheck are
526 written to the binary log. Use --skip-write-binlog to cause
527 NO_WRITE_TO_BINLOG to be added to the statements so that they are
528 not logged. Use the --skip-write-binlog when these statements
529 should not be sent to replication slaves or run when using the
530 binary logs for recovery from backup.
531
532 · --zstd-compression-level=level The compression level to use for
533 connections to the server that use the zstd compression algorithm.
534 The permitted levels are from 1 to 22, with larger values
535 indicating increasing levels of compression. The default zstd
536 compression level is 3. The compression level setting has no effect
537 on connections that do not use zstd compression.
538
539 For more information, see Section 4.2.6, “Connection Compression
540 Control”.
541
542 This option was added in MySQL 8.0.18.
543
545 Copyright © 1997, 2020, Oracle and/or its affiliates. All rights
546 reserved.
547
548 This documentation is free software; you can redistribute it and/or
549 modify it only under the terms of the GNU General Public License as
550 published by the Free Software Foundation; version 2 of the License.
551
552 This documentation is distributed in the hope that it will be useful,
553 but WITHOUT ANY WARRANTY; without even the implied warranty of
554 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
555 General Public License for more details.
556
557 You should have received a copy of the GNU General Public License along
558 with the program; if not, write to the Free Software Foundation, Inc.,
559 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA or see
560 http://www.gnu.org/licenses/.
561
562
564 For more information, please refer to the MySQL Reference Manual, which
565 may already be installed locally and which is also available online at
566 http://dev.mysql.com/doc/.
567
569 Oracle Corporation (http://dev.mysql.com/).
570
571
572
573MySQL 8.0 03/06/2020 MYSQLCHECK(1)