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           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 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--pipe, -W On Windows, connect to the server using a named pipe.
295           This option applies only if the server was started with the
296           named_pipe system variable enabled to support named-pipe
297           connections. In addition, the user making the connection must be a
298           member of the Windows group specified by the
299           named_pipe_full_access_group system variable.
300
301--plugin-dir=dir_name The directory in which to look for plugins.
302           Specify this option if the --default-auth option is used to specify
303           an authentication plugin but mysqlcheck does not find it. See
304           Section 6.2.17, “Pluggable Authentication”.
305
306--port=port_num, -P port_num For TCP/IP connections, the port
307           number to use.
308
309--print-defaults Print the program name and all options that it
310           gets from option files.
311
312           For additional information about this and other option-file
313           options, see Section 4.2.2.3, “Command-Line Options that Affect
314           Option-File Handling”.
315
316--protocol={TCP|SOCKET|PIPE|MEMORY} The transport protocol to use
317           for connecting to the server. It is useful when the other
318           connection parameters normally result in use of a protocol other
319           than the one you want. For details on the permissible values, see
320           Section 4.2.7, “Connection Transport Protocols”.
321
322--quick, -q If you are using this option to check tables, it
323           prevents the check from scanning the rows to check for incorrect
324           links. This is the fastest check method.
325
326           If you are using this option to repair tables, it tries to repair
327           only the index tree. This is the fastest repair method.
328
329--repair, -r Perform a repair that can fix almost anything except
330           unique keys that are not unique.
331
332--server-public-key-path=file_name The path name to a file in PEM
333           format containing a client-side copy of the public key required by
334           the server for RSA key pair-based password exchange. This option
335           applies to clients that authenticate with the sha256_password or
336           caching_sha2_password authentication plugin. This option is ignored
337           for accounts that do not authenticate with one of those plugins. It
338           is also ignored if RSA-based password exchange is not used, as is
339           the case when the client connects to the server using a secure
340           connection.
341
342           If --server-public-key-path=file_name is given and specifies a
343           valid public key file, it takes precedence over
344           --get-server-public-key.
345
346           For sha256_password, this option applies only if MySQL was built
347           using OpenSSL.
348
349           For information about the sha256_password and caching_sha2_password
350           plugins, see Section 6.4.1.3, “SHA-256 Pluggable Authentication”,
351           and Section 6.4.1.2, “Caching SHA-2 Pluggable Authentication”.
352
353--shared-memory-base-name=name On Windows, the shared-memory name
354           to use for connections made using shared memory to a local server.
355           The default value is MYSQL. The shared-memory name is
356           case-sensitive.
357
358           This option applies only if the server was started with the
359           shared_memory system variable enabled to support shared-memory
360           connections.
361
362--silent, -s Silent mode. Print only error messages.
363
364--skip-database=db_name Do not include the named database
365           (case-sensitive) in the operations performed by mysqlcheck.
366
367--socket=path, -S path For connections to localhost, the Unix
368           socket file to use, or, on Windows, the name of the named pipe to
369           use.
370
371           On Windows, this option applies only if the server was started with
372           the named_pipe system variable enabled to support named-pipe
373           connections. In addition, the user making the connection must be a
374           member of the Windows group specified by the
375           named_pipe_full_access_group system variable.
376
377--ssl* Options that begin with --ssl specify whether to connect to
378           the server using encryption and indicate where to find SSL keys and
379           certificates. See the section called “Command Options for Encrypted
380           Connections”.
381
382--ssl-fips-mode={OFF|ON|STRICT} Controls whether to enable FIPS
383           mode on the client side. The --ssl-fips-mode option differs from
384           other --ssl-xxx options in that it is not used to establish
385           encrypted connections, but rather to affect which cryptographic
386           operations to permit. See Section 6.8, “FIPS Support”.
387
388           These --ssl-fips-mode values are permitted:
389
390           •   OFF: Disable FIPS mode.
391
392           •   ON: Enable FIPS mode.
393
394           •   STRICT: Enable “strict” FIPS mode.
395
396
397               Note
398               If the OpenSSL FIPS Object Module is not available, the only
399               permitted value for --ssl-fips-mode is OFF. In this case,
400               setting --ssl-fips-mode to ON or STRICT causes the client to
401               produce a warning at startup and to operate in non-FIPS mode.
402
403--tables Override the --databases or -B option. All name arguments
404           following the option are regarded as table names.
405
406--tls-ciphersuites=ciphersuite_list The permissible ciphersuites
407           for encrypted connections that use TLSv1.3. The value is a list of
408           one or more colon-separated ciphersuite names. The ciphersuites
409           that can be named for this option depend on the SSL library used to
410           compile MySQL. For details, see Section 6.3.2, “Encrypted
411           Connection TLS Protocols and Ciphers”.
412
413           This option was added in MySQL 8.0.16.
414
415--tls-version=protocol_list The permissible TLS protocols for
416           encrypted connections. The value is a list of one or more
417           comma-separated protocol names. The protocols that can be named for
418           this option depend on the SSL library used to compile MySQL. For
419           details, see Section 6.3.2, “Encrypted Connection TLS Protocols and
420           Ciphers”.
421
422--use-frm For repair operations on MyISAM tables, get the table
423           structure from the data dictionary so that the table can be
424           repaired even if the .MYI header is corrupted.
425
426--user=user_name, -u user_name The user name of the MySQL account
427           to use for connecting to the server.
428
429--verbose, -v Verbose mode. Print information about the various
430           stages of program operation.
431
432--version, -V Display version information and exit.
433
434--write-binlog This option is enabled by default, so that ANALYZE
435           TABLE, OPTIMIZE TABLE, and REPAIR TABLE statements generated by
436           mysqlcheck are written to the binary log. Use --skip-write-binlog
437           to cause NO_WRITE_TO_BINLOG to be added to the statements so that
438           they are not logged. Use the --skip-write-binlog when these
439           statements should not be sent to replicas or run when using the
440           binary logs for recovery from backup.
441
442--zstd-compression-level=level The compression level to use for
443           connections to the server that use the zstd compression algorithm.
444           The permitted levels are from 1 to 22, with larger values
445           indicating increasing levels of compression. The default zstd
446           compression level is 3. The compression level setting has no effect
447           on connections that do not use zstd compression.
448
449           For more information, see Section 4.2.8, “Connection Compression
450           Control”.
451
452           This option was added in MySQL 8.0.18.
453
455       Copyright © 1997, 2021, Oracle and/or its affiliates.
456
457       This documentation is free software; you can redistribute it and/or
458       modify it only under the terms of the GNU General Public License as
459       published by the Free Software Foundation; version 2 of the License.
460
461       This documentation is distributed in the hope that it will be useful,
462       but WITHOUT ANY WARRANTY; without even the implied warranty of
463       MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
464       General Public License for more details.
465
466       You should have received a copy of the GNU General Public License along
467       with the program; if not, write to the Free Software Foundation, Inc.,
468       51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA or see
469       http://www.gnu.org/licenses/.
470
471

SEE ALSO

473       For more information, please refer to the MySQL Reference Manual, which
474       may already be installed locally and which is also available online at
475       http://dev.mysql.com/doc/.
476

AUTHOR

478       Oracle Corporation (http://dev.mysql.com/).
479
480
481
482MySQL 8.0                         03/07/2021                     MYSQLCHECK(1)
Impressum