1MYSQLCHECK(1)               MariaDB 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. Table maintenance operations can be
18       time-consuming, particularly for large tables. If you use the
19       --databases or --all-databases option to process all tables in one or
20       more databases, an invocation of mysqlcheck might take a long time.
21       (This is also true for mysql_upgrade because that program invokes
22       mysqlcheck to check all tables and repair them if necessary.)
23
24       mysqlcheck is similar in function to myisamchk, but works differently.
25       The main operational difference is that mysqlcheck must be used when
26       the mysqld server is running, whereas myisamchk should be used when it
27       is not. The benefit of using mysqlcheck is that you do not have to stop
28       the server to perform table maintenance.
29
30       mysqlcheck uses the SQL statements CHECK TABLE, REPAIR TABLE, ANALYZE
31       TABLE, and OPTIMIZE TABLE in a convenient way for the user. It
32       determines which statements to use for the operation you want to
33       perform, and then sends the statements to the server to be executed.
34
35       The MyISAM storage engine supports all four maintenance operations, so
36       mysqlcheck can be used to perform any of them on MyISAM tables. Other
37       storage engines do not necessarily support all operations. In such
38       cases, an error message is displayed. For example, if test.t is a
39       MEMORY table, an attempt to check it produces this result:
40
41           shell> mysqlcheck test t
42           test.t
43           note     : The storage engine for the table doesn´t support check
44
45       If mysqlcheck is unable to repair a table, see the MariaDB Knowledge
46       Base for manual table repair strategies. This will be the case, for
47       example, for InnoDB tables, which can be checked with CHECK TABLE, but
48       not repaired with REPAIR TABLE.
49
50       The use of mysqlcheck with partitioned tables is not supported.
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 following names can be used to change mysqlcheck default behavior.
75
76       ┌──────────────┬───────────────────────┐
77mysqlrepair   │ The default option is │
78       │              │ --repair              
79       ├──────────────┼───────────────────────┤
80mysqlanalyze  │ The default option is │
81       │              │ --analyze             
82       ├──────────────┼───────────────────────┤
83mysqloptimize │ The default option is │
84       │              │ --optimize            
85       └──────────────┴───────────────────────┘
86
87       mysqlcheck supports the following options, which can be specified on
88       the command line or in the [mysqlcheck] and [client] option file
89       groups.  The -c, -r, -a and -o options are exclusive to each other.
90
91--help, -?
92
93           Display a help message and exit.
94
95--all-databases, -A
96
97           Check all tables in all databases. This is the same as using the
98           --databases option and naming all the databases on the command
99           line.
100
101--all-in-1, -1
102
103           Instead of issuing a statement for each table, execute a single
104           statement for each database that names all the tables from that
105           database to be processed.
106
107--analyze, -a
108
109           Analyze the tables.
110
111--auto-repair
112
113           If a checked table is corrupted, automatically fix it. Any
114           necessary repairs are done after all tables have been checked.
115
116--character-sets-dir=path
117
118           The directory where character sets are installed.
119
120--check, -c
121
122           Check the tables for errors. This is the default operation.
123
124--check-only-changed, -C
125
126           Check only tables that have changed since the last check or that
127           have not been closed properly.
128
129--check-upgrade, -g
130
131           Invoke CHECK TABLE with the FOR UPGRADE option to check tables for
132           incompatibilities with the current version of the server. This
133           option automatically enables the --fix-db-names and
134           --fix-table-names options.
135
136--compress
137
138           Compress all information sent between the client and the server if
139           both support compression.
140
141--databases, -B
142
143           Process all tables in the named databases. Normally, mysqlcheck
144           treats the first name argument on the command line as a database
145           name and following names as table names. With this option, it
146           treats all name arguments as database names.
147
148--debug[=debug_options], -# [debug_options]
149
150           Write a debugging log. A typical debug_options string is
151           ´d:t:o,file_name´. The default is ´d:t:o´.
152
153--debug-check
154
155           Print some debugging information when the program exits.
156
157--debug-info
158
159           Print debugging information and memory and CPU usage statistics
160           when the program exits.
161
162--default-auth=name
163
164           Default authentication client-side plugin to use.
165
166--default-character-set=charset_name
167
168           Use charset_name as the default character set.
169
170--defaults-extra-file=filename
171
172           Set filename as the file to read default options from after the
173           global defaults files has been read.  Must be given as first
174           option.
175
176--defaults-file=filename
177
178           Set filename as the file to read default options from, override
179           global defaults files.  Must be given as first option.
180
181--extended, -e
182
183           If you are using this option to check tables, it ensures that they
184           are 100% consistent but takes a long time.
185
186           If you are using this option to repair tables, it will force using
187           the old, slow, repair with keycache method, instead of the much
188           faster repair by sorting.
189
190--fast, -F
191
192           Check only tables that have not been closed properly.
193
194--fix-db-names
195
196           Convert database names to the format used since MySQL 5.1. Only
197           database names that contain special characters are affected.
198
199--fix-table-names
200
201           Convert table names (including views) to the format used since
202           MySQL 5.1. Only table names that contain special characters are
203           affected.
204
205--flush,
206
207           Flush each table after check. This is useful if you don't want to
208           have the checked tables take up space in the caches after the
209           check.
210
211--force, -f
212
213           Continue even if an SQL error occurs.
214
215--host=host_name, -h host_name
216
217           Connect to the MariaDB server on the given host.
218
219--medium-check, -m
220
221           Do a check that is faster than an --extended operation. This finds
222           only 99.99% of all errors, which should be good enough in most
223           cases.
224
225--no-defaults
226
227           Do not read default options from any option file. This must be
228           given as the first argument.
229
230--optimize, -o
231
232           Optimize the tables.
233
234--password[=password], -p[password]
235
236           The password to use when connecting to the server. If you use the
237           short option form (-p), you cannot have a space between the option
238           and the password. If you omit the password value following the
239           --password or -p option on the command line, mysqlcheck prompts for
240           one.
241
242           Specifying a password on the command line should be considered
243           insecure. You can use an option file to avoid giving the password
244           on the command line.
245
246--persistent, -Z
247
248           Used with ANALYZE TABLE to append the option PERSISENT FOR ALL.
249
250--pipe, -W
251
252           On Windows, connect to the server via a named pipe. This option
253           applies only if the server supports named-pipe connections.
254
255--plugin-dir=name
256
257            Directory for client-side plugins.
258
259--port=port_num, -P port_num
260
261           The TCP/IP port number to use for the connection.
262
263--print-defaults
264
265           Print the program argument list and exit.  This must be given as
266           the first argument.
267
268--process-tables
269
270           Perform the requested operation on tables. Defaults to on; use
271           --skip-process-tables to disable.
272
273--process-views=val
274
275           Perform the requested operation (only CHECK VIEW or REPAIR VIEW).
276           Possible values are NO, YES (correct the checksum, if necessary,
277           add the mariadb-version field), UPGRADE_FROM_MYSQL (same as YES and
278           toggle the algorithm MERGE<->TEMPTABLE.
279
280--protocol={TCP|SOCKET|PIPE|MEMORY}
281
282           The connection protocol to use for connecting to the server. It is
283           useful when the other connection parameters normally would cause a
284           protocol to be used other than the one you want.
285
286--quick, -q
287
288           If you are using this option to check tables, it prevents the check
289           from scanning the rows to check for incorrect links. This is the
290           fastest check method.
291
292           If you are using this option to repair tables, it tries to repair
293           only the index tree. This is the fastest repair method.
294
295--repair, -r
296
297           Perform a repair that can fix almost anything except unique keys
298           that are not unique.
299
300--silent, -s
301
302           Silent mode. Print only error messages.
303
304--skip-database=db_name -s
305
306           Don't process the database (case-sensitive) specified as argument.
307
308--socket=path, -S path
309
310           For connections to localhost, the Unix socket file to use, or, on
311           Windows, the name of the named pipe to use.
312
313--ssl
314
315           Enable SSL for connection (automatically enabled with other flags).
316           Disable with --skip-ssl.
317
318--ssl-ca=name
319
320           CA file in PEM format (check OpenSSL docs, implies --ssl).
321
322--ssl-capath=name
323
324           CA directory (check OpenSSL docs, implies --ssl).
325
326--ssl-cert=name
327
328           X509 cert in PEM format (check OpenSSL docs, implies --ssl).
329
330--ssl-cipher=name
331
332           SSL cipher to use (check OpenSSL docs, implies --ssl).
333
334--ssl-key=name
335
336           X509 key in PEM format (check OpenSSL docs, implies --ssl).
337
338--ssl-crl=name
339
340           Certificate revocation list (check OpenSSL docs, implies --ssl).
341
342--ssl-crlpath=name
343
344           Certificate revocation list path (check OpenSSL docs, implies
345           --ssl).
346
347--ssl-verify-server-cert
348
349           Verify server's "Common Name" in its cert against hostname used
350           when connecting. This option is disabled by default.
351
352--tables
353
354           Override the --databases or -B option. All name arguments following
355           the option are regarded as table names.
356
357--use-frm
358
359           For repair operations on MyISAM tables, get the table structure
360           from the .frm file so that the table can be repaired even if the
361           .MYI header is corrupted.
362
363--user=user_name, -u user_name
364
365           The MariaDB user name to use when connecting to the server.
366
367--verbose, -v
368
369           Verbose mode. Print information about the various stages of program
370           operation.  Using one --verbose option will give you more
371           information about what mysqlcheck is doing.
372
373           Using two --verbose options will also give you connection
374           information.
375
376           Using it 3 times will print out all CHECK, RENAME and ALTER TABLE
377           during the check phase.
378
379--version, -V
380
381           Display version information and exit.
382
383--write-binlog
384
385           This option is enabled by default, so that ANALYZE TABLE, OPTIMIZE
386           TABLE, and REPAIR TABLE statements generated by mysqlcheck are
387           written to the binary log. Use --skip-write-binlog to cause
388           NO_WRITE_TO_BINLOG to be added to the statements so that they are
389           not logged. Use the --skip-write-binlog when these statements
390           should not be sent to replication slaves or run when using the
391           binary logs for recovery from backup.
392
394       Copyright 2007-2008 MySQL AB, 2008-2010 Sun Microsystems, Inc.,
395       2010-2019 MariaDB Foundation
396
397       This documentation is free software; you can redistribute it and/or
398       modify it only under the terms of the GNU General Public License as
399       published by the Free Software Foundation; version 2 of the License.
400
401       This documentation is distributed in the hope that it will be useful,
402       but WITHOUT ANY WARRANTY; without even the implied warranty of
403       MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
404       General Public License for more details.
405
406       You should have received a copy of the GNU General Public License along
407       with the program; if not, write to the Free Software Foundation, Inc.,
408       51 Franklin Street, Fifth Floor, Boston, MA 02110-1335 USA or see
409       http://www.gnu.org/licenses/.
410
411

SEE ALSO

413       For more information, please refer to the MariaDB Knowledge Base,
414       available online at https://mariadb.com/kb/
415

AUTHOR

417       MariaDB Foundation (http://www.mariadb.org/).
418
419
420
421MariaDB 10.5                     27 June 2019                    MYSQLCHECK(1)
Impressum