Mysqlcheck: Table maintenance and repair procedures

Source: Internet
Author: User
Tags character set socket sql error port number

The Mysqlcheck client can examine and repair the MyISAM table. It can also optimize and analyze tables.

Mysqlcheck function is similar to MYISAMCHK, but its work is different. The main difference is that when the MYSQLD server has to use Mysqlcheck at run time, Myisamchk applies to the server when it is not running. The advantage of using Mysqlcheck is that you do not need to stop the server to check or fix the table.

Mysqlcheck provides a convenient way for users to use SQL statements check table, REPAIR table, ANALYZE table, and optimize table. It determines which statement is used in the operation to be performed, and then sends the statement to the server to be executed.

There are 3 different ways to invoke Mysqlcheck:

shell> mysqlcheck[options] db_name [tables]

Shell> Mysqlcheck[options]---database DB1 [DB2 DB3 ...]

Shell> Mysqlcheck[options]--all--database

If you do not specify any tables or use the---database or--all--database option, check the entire database.

Compared with other clients, Mysqlcheck has a special feature. Renaming the binary allows you to change the default behavior of the checklist (--check). If you want a tool that can fix a table by default, simply copy Mysqlcheck to Mysqlrepair or use a symbolic link mysqlrepair link mysqlcheck. If you call Mysqlrepair, you can repair the table by command.

The following name can be used to change the default behavior of Mysqlcheck:

Mysqlrepair The default option is--repair
Mysqlanalyze The default option is--analyze
Mysqloptimize The default option is--optimize

Mysqlcheck

The following options are supported:

· ---help,-?

Displays a help message and exits.

· --all--database,-a

Check all tables in all databases. As with the---database option, all databases are named on the command line.

· --all-in-1,-1

Instead of issuing a statement for each table, you execute a statement for each database in the named database for all the tables that are being processed.

· --analyze,-a

Analysis table.

· --auto-repair

If a checked table is corrupted, fix it automatically. All required repairs are done automatically after checking all tables.

· --character-sets-dir=path

The installation directory for the character set. See section 5.10.1, "Data and sorting with character sets."

· --check,-c

Check the table for errors.

· --check-only-changed,-c

Checks only those tables that have changed since the last check or have not been properly closed.

· --compress

Compresses all information sent between the client and the server, if both support compression.

· ---database,-b

Handles all the tables named in the database. With this option, all Word name parameters are treated as database names, not table names.

· ---debug[=debug_options],-# [debug_options]

Write debug Log. The debug_options string is usually ' d:t:o,file_name '.

· --default-character-set=charset

Use the Charsetas default character set. See section 5.10.1, "Data and sorting with character sets."

· --extended,-e

If you are using this option to check the table, make sure that they are 100% consistent, but will take a long time.

If you are using this option to fix the table, run the extended fix, not only for a very long time, but also for a lot of garbage rows!

· --fast,-f

Only check for tables that are not properly closed.

· --force,-f

Continue even if a SQL error occurs.

· --host=host_name,-h host_name

Connect to a MySQL server on a given host.

· --medium-check,-m

Perform a faster check than the--extended operation. Only 99.99% of the errors can be found, and in most cases this is enough.

· --optimize,-o

Tuning tables.

· --password[=password],-p[password]

The password to use when connecting to the server. If you use the Short option form (-p), there is no space between the option and the password. If you do not have a password value after the--password or P option on the command line, you are prompted to enter a password.

· --port=port_num,-p Port_num

The TCP/IP port number to use for the connection.

· --protocol={tcp | SOCKET | PIPE | MEMORY}

The connection agreement used.

· --quick,-q

If you are using this option in the checklist, it prevents scan rows to check for error link checks. This is the quickest way to check.

If you are using this option in the repair table, it tries to repair only the index tree. This is the quickest way to fix it.

· --repair,-r

Perform fixes that can fix most problems, except that the unique values are not fixed for a while.

· --silent,-s

Silent mode. Only error messages are printed.

· --socket=path,-s Path

The socket file to use for the connection.

· --tables

Overwrite---database or-b option. All parameters after the option are treated as table names.

· --user=user_name,-u user_name

The MySQL user name to use when connecting to the server.

· --verbose,-v

Verbose mode. Print information about program actions for each stage.

· --version,-v

Displays version information and exits.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.