A detailed analysis of MySQL Database Mysqlcheck optimization table

Source: Internet
Author: User
Tags db2 sql error


MySQL has 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 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. Using MYISAMCHK to repair failures is irreversible.

Usage:

Mysqlcheck [OPTIONS] database [tables]
Mysqlcheck [options]–databases DB1 [DB2 DB3 ...]
Mysqlcheck [options]–all-databases

Common options:

-A All databases
-a analysis of the specified table
-C Check Library or table
-R Repair Library or table
-O Optimization specified table
-H MySQL Service host
-P Port
-U user Name
-p password
--auto-repair Repair Damaged Table

1, if you need to check and repair all the data tables of the database, then you can use:

/usr/local/mysql/bin/mysqlcheck-uroot-p-o-a

Enter Password:

After entering the password, you can optimize all the databases.

2, if you need to repair the specified database with


/usr/local/mysql/bin/mysqlcheck-p DATABASE

The most commonly used is these two kinds of ~ ~


Mysqlcheck supports the following options:

· ---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

Display version information and exit

Related Article

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.