Mysql in the optimization and Repair Database Tools Mysqlcheck Detailed Introduction _mysql

Source: Internet
Author: User
Tags db2 mysql in mysql version sql error

Introduction of Mysqlcheck

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

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.

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

Second, the use of Mysqlcheck

1. There are 3 different ways to invoke Mysqlcheck:

Copy Code code as follows:

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.

2. Fix all the databases

Copy Code code as follows:
Mysqlcheck-a-c-o-r-m--all-databases-uroot-p

Use the above command to optimize all databases

Parameter implication:

Copy Code code as follows:
-A = analyse given tables.
-c = Check table for errors
-O = Optimise table
-r = Can fix almost anything except unique keys that aren ' t unique
-M =--medium-check

Note: When the MySQL version is 5.5, please delete the-O in the command

3. Fix the specified database

Copy Code code as follows:
Mysqlcheck-o-r-uroot-p888888 Dataname
mysqlcheck-hlocalhost-auto-repair-uroot-p****** Dataname

4. With a simple talk about mysqlcheck use of detailed
Usage:

Copy Code code as follows:
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

Iii. acquisition of Mysqlcheck.exe

Download the MySQL installation package for your version number via mysql.com (Noinstall no need to install version). This command is installed after the MySQL database is installed, under the path Mysql\mysql server 5.0\bin.


Four, Mysqlcheck parameter detailed:

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

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.