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

SEE ALSO

503       For more information, please refer to the MySQL Reference Manual, which
504       may already be installed locally and which is also available online at
505       http://dev.mysql.com/doc/.
506

AUTHOR

508       Oracle Corporation (http://dev.mysql.com/).
509
510
511
512MySQL 8.0                         08/31/2023                     MYSQLCHECK(1)
Impressum