myisamchk


myisamchk

myisamchk options table[.MYI][...]

Use this to check and repair MyISAM tables, as well as to optimize them. This utility works with the table files directly and does not require interaction with the MySQL server. Therefore, it may be necessary to specify the path along with the table or table names in the second argument. Also, tables that are being checked should be locked or the MySQL server daemon should be stopped. This utility works with the index files for the tables, so the suffix .MYI may be given for table names to prevent it from attempting to analyze other files. Providing no suffix (e.g., table1, not table1.*) will have the same effect as giving a specific one (table1.MYI). To check all of the tables in a database, use the wildcard (i.e., *.MYI). Here is a basic example of how you can use myisamchk to check one table:

myisamchk /data/mysql/workrequests/requests Checking MyISAM file: /data/mysql/workrequests/requests Data records:     531   Deleted blocks:       0 myisamchk: warning: 3 clients is using or hasn't closed the table properly - check file-size - check key delete-chain - check record delete-chain - check index reference - check data record references index: 1 - check record links MyISAM-table '/data/mysql/workrequests/requests' is usable but should be fixed

No options are specified here, so the default of --check is used. Notice that myisamchk detected a problem with the table. To fix this problem, you can run the utility again, but with the --recover option like so:

myisamchk --recover /data/mysql/workrequests/requests - recovering (with sort) MyISAM-table  '/data/mysql/workrequests/requests' Data records: 531 - Fixing index 1

The following sections list of the options available with myisamchk.

Check options


--check, -c

Instructs the utility to check tables for errors.


--check-only-changed, -C

Instructs the utility to check only tables that have changed since the last check.


--extend-check, -e

Instructs the utility to check tables thoroughly. Use this option only in extreme cases.


--fast, -F

Use this option to have the utility check only tables that haven't been closed properly.


--force, -f

Instructs the utility to repair tables that report errors during check mode. It restarts the utility with the --recover option if any errors occur.


--information, -i

Displays statistical information about tables being checked.


--medium-check, -m

Instructs the utility to check tables more thoroughly than --check, but not as thoroughly as --extend-check.


--read-only, -T

Tells the utility not to mark tables with status information so that tables may be used while checking. Tables are not marked as checked when using this option.


--update-state, -U

Has the utility update tables to indicate when they were checked and mark them as crashed if any errors are found.

Repair options


--backup, -B

Instructs the utility to make a copy of datafiles (table.MYD), naming them table-datetime.BAK.


--character-sets-dir= path

Sets the directory where character sets are located.


--correct-checksum

Corrects a table's checksum information.


--data-file-length= number, -D number

Sets the maximum length of a datafile for when rebuilding a full datafile.


--extend-check, -e

Instructs the utility to attempt to recover all rows, including intentionally deleted ones.


--force, -f

Instructs the utility to ignore error messages and to overwrite temporary files.


--keys-used= bitfield, -k bitfield

Instructs the utility to have MyISAM updates use only specific keys for faster data inserts.


--max-record-length= number

Tells the utility to skip rows larger than the length specified if there is not enough memory.


--parallel-recover, -p

This option is the same as the --recover option, but instructs the utility to create all keys in parallel with different threads.


--quick, -q

Repairs indexes only and not datafiles of tables that are not corrupted.


-qq

Repairs indexes only and updates datafiles only when duplicates are found.


--safe-recover, -o

Repairs rows that the --sort-recover option cannot handle (e.g., duplicate values for unique keys).


--set-character-set= set

Specifies the character set to use.


--sort-recover, -n

Instructs the utility to use the sort buffer regardless of whether the temporary file would be too large based on default limits.


--unpack, -u

Unpacks tables that were packed with the myisampack utility.

Other options


--analyze, -a

Instructs the utility to optimize the use of keys in tables. This option can help with some joins. Use the --description and the --verbose options to show the calculated distribution.


--block-search= offset, -b offset

Searches for a row based on a given offset.


--description, -d

Displays information about the table.


--set-auto-increment[= value], -A [ value]

Sets the value of an auto-increment column for the next row created. If no value is given, the next value above the highest value found for column is used.


--sort-index, -S

Sorts indexes.


--sort-records= index, -R index

Sorts rows based on the index given.

Global options


--debug= options, -# options

Sets debug option to log (e.g., `d:t:o, filename').


--character-sets-dir= path

Specifies the directory containing character sets.


--help, -?

Displays basic help information.


--silent, -s

Displays only print error messages. With -ss even less information will be displayed.


--sort-index, -S

Sorts indexes.


--sort-records= value, -R value

Instructs the utility to sort records based on the index given.


--tmpdir= path, -t path

Sets the path for temporary files. Additional paths may be given in a colon-separated list.


--verbose, -v

Displays more information. Additional vs (e.g., -vv) will provide more information.


--version, -V

Displays the version of the utility.


--wait, -w

Instructs the utility to wait before proceeding if the table is locked.



MySQL in a Nutshell
MYSQL in a Nutshell (In a Nutshell (OReilly))
ISBN: 0596514336
EAN: 2147483647
Year: 2006
Pages: 134
Authors: Russell Dyer

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net