mysqlcheck

Stai visualizzando una vecchia versione di questo article. Visualizza la versione più recente.

mysqlcheck è uno strumento di manutenzione che permette di verificare, riparare, analizzare e ottimizzare più tabelle in una volta dalla riga di comando.

Utilizzo:

./client/mysqlcheck [OPZIONI] database [tabelle]

OR

./client/mysqlcheck [OPZIONI] --databases DB1 [DB2 DB3...]

OR

./client/mysqlcheck [OPZIONI] --all-databases

mysqlcheck serve a effettuare un CHECK (-c, -m, -C), un REPAIR (-r), un ANALYZE (-a) o un OPTIMIZE (-o). Alcune delle opzioni (come -e o -q) possono essere usate allo stesso tempo. Non tutte le opzioni sono supportate da tutti gli Storage Engine.

Le opzioni -c, -r, -a e -o sono mutualmente esclusive, il che significa che se si specificano più opzioni solo l'ultima verrà presa in considerazione.

L'opzione --check viene usata per default, se nessun'altra è specificata. E' possibile cambiare il comportamento di default facendo un link simbolico al binario, o copiandolo con un altro nome; le alternative sono:

mysqlrepairL'opzione di default sarà -r (--repair)
mysqlanalyzeL'opzione di default sarà -a (--analyze)
mysqloptimizeL'opzione di default sarà -o (--optimize)

Vengono letti i gruppi [mysqlcheck] e [client] dai file my.cnf.

The following options to handle option files may be given as the first argument:

--print-defaultsPrint the program argument list and exit.
--no-defaultsDon't read default options from any option file.
--defaults-file=# Only read default options from the given file #.
--defaults-extra-file=# Read this file after the global files are read.

Main arguments are:

-A, --all-databasesCheck all the databases. This is the same as --databases with all databases selected.
-a, --analyzeAnalyze given tables.
-1, --all-in-1Instead of issuing one query for each table, use one query per database, naming all tables in the database in a comma-separated list.
--auto-repairIf a checked table is corrupted, automatically fix it. Repairing will be done after all tables have been checked, if corrupted ones were found.
--character-sets-dir=nameDirectory for character set files.
-c, --checkCheck table for errors.
-C, --check-only-changedCheck only tables that have changed since last check or haven't been closed properly.
-g, --check-upgradeCheck tables for version-dependent changes. May be used with --auto-repair to correct tables requiring version-dependent updates. Used when upgrading
--compressUse compression in server/client protocol.
-B, --databasesCheck several databases. Note the difference in usage; in this case no tables are given. All name arguments are regarded as database names.
-# , --debug[=name]Output debug log. Often this is 'd:t:o,filename'.
--debug-checkCheck memory and open file usage at exit.
--debug-infoPrint some debug info at exit.
--default-character-set=nameSet the default character set.
-F, --fastCheck only tables that haven't been closed properly.
--fix-db-namesFix database names. Used when upgrading
--fix-table-namesFix table names. Used when upgrading
--flushFlush each table after check. This is useful if you don't want to have the checked tables take up space in the caches after the check.
-f, --forceContinue even if we get an SQL error.
-e, --extendedIf you are using this option with --check, it will ensure that the table is 100 percent consistent, but will take a long time. If you are using this option with --repair, it will force using old slow repair with keycache method, instead of much faster repair by sorting.
-?, --helpDisplay this help message and exit.
-h, --host=nameConnect to host.
-m, --medium-checkFaster than extended-check, but only finds 99.99 percent of all errors. Should be good enough for most cases.
--write-binlogLog ANALYZE, OPTIMIZE and REPAIR TABLE commands. Enabled by default; use --skip-write-binlog when commands should not be sent to replication slaves.
-o, --optimizeOptimize table.
-p, --password[=name]Password to use when connecting to server. If password is not given, it's solicited on the tty.
-P, --port=# Port number to use for connection or 0 for default to, in order of preference, my.cnf, $MYSQL_TCP_PORT, /etc/services, built-in default (3306).
--protocol=nameThe protocol to use for connection (tcp, socket, pipe, memory).
-q, --quickIf you are using this option with CHECK TABLE, it prevents the check from scanning the rows to check for wrong links. This is the fastest check. If you are using this option with REPAIR TABLE, it will try to repair only the index tree. This is the fastest repair method for a table.
-r, --repairCan fix almost anything except unique keys that aren't unique.
-s, --silentPrint only error messages.
-S, --socket=nameThe socket file to use for connection.
--sslEnable SSL for connection (automatically enabled with other flags). Disable with '--skip-ssl'.
--ssl-ca=nameCA file in PEM format (check OpenSSL docs, implies --ssl).
--ssl-capath=nameCA directory (check OpenSSL docs, implies --ssl).
--ssl-cert=nameX509 cert in PEM format (implies --ssl).
--ssl-cipher=nameSSL cipher to use (implies --ssl).
--ssl-key=nameX509 key in PEM format (implies --ssl).
--ssl-verify-server-certVerify server's "Common Name" in its cert against hostname used when connecting. This option is disabled by default.
--tablesOverrides option --databases (-B).
--use-frmWhen used with REPAIR, get table structure from .frm file, so the table can be repaired even if .MYI header is corrupted.
-u, --user=nameUser for login if not current user.
-v, --verbosePrint info about the various stages. You can give this option several times to get even more information.
-V, --versionOutput version information and exit.

To see the default values for the options and also to see the arguments you get from configuration files you can do:

./client/mysqlcheck --print-defaults
./client/mysqlcheck --help

When running mysqlcheck with --auto-repair (as done by mysql_upgrade), mysqlcheck will first check all tables and then in a separate phase repair those that failed the check.

mysqlcheck --all-databases will ignore the MySQL internal log tables 'general_log' and 'slow_log' as these can't be checked, repaired or optimized.

Commenti

Sto caricando i commenti......
Content reproduced on this site is the property of its respective owners, and this content is not reviewed in advance by MariaDB. The views, information and opinions expressed by this content do not necessarily represent those of MariaDB or any other party.