描述、校驗及修復 MyISAM 錶。
不帶選項使用時,將檢查命令中的所有錶格是否齣錯。
安裝命令:apt-get install myisamchk
另請參閱: mysql
修正 pre_k_spider 數據庫錶錯誤
root:/# cd /var/lib/mysql/ultrax root:/var/lib/mysql/ultrax# myisamchk -f -r ./pre_k_spider myisamchk: [Warning] World-writable config file '/etc/mysql/my.cnf' is ignored. myisamchk: error: 140 when opening MyISAM-table './pre_k_spider.MYI' root:/var/lib/mysql/ultrax# myisamchk -f -r ./pre_k_spider myisamchk: [Warning] World-writable config file '/etc/mysql/my.cnf' is ignored. - recovering (with sort) MyISAM-table './pre_k_spider' Data records: 90671 - Fixing index 1 Data records: 90668 root:/var/lib/mysql/ultrax#
修正 pre_forum_threadaddviews 數據庫錶錯誤
root:/# cd /var/lib/mysql/ultrax root:/var/lib/mysql/ultrax# myisamchk -f -r ./pre_forum_threadaddviews myisamchk: [Warning] World-writable config file '/etc/mysql/my.cnf' is ignored. - recovering (with sort) MyISAM-table './pre_forum_threadaddviews' Data records: 725 - Fixing index 1 root:/var/lib/mysql/ultrax#
基本語法
myisamchk [OPTIONS] tables[.MYI]
默認選項讀取自下列文件按給定次序:
/etc/my.cnf
/etc/mysql/my.cnf
~/.my.cnf
全局選項
| 參數 | EN 解釋 | 中文翻譯 | 備注 |
|---|---|---|---|
| -H, --HELP | Display this help and exit. | 顯示此幫助並退齣。 | |
| -?, --help | Display this help and exit. | 顯示此幫助並退齣。 | |
| -t, --tmpdir=path |
Path for temporary files. Multiple paths can be specified, separated by colon (:), they will be used in a round-robin fashion. |
臨時文件路徑。 可以按 : 冒號分隔指定多個路徑,將以循環方式使用它們。 |
|
| -s, --silent |
Only print errors. One can use two -s to make myisamchk very silent. |
隻打印錯誤。 一次可以使用兩個 -s 以使 myisamchk 非常安靜。 |
|
| -v, --verbose |
Print more information. This can be used with --description and --check. Use many -v for more verbosity. |
打印更多信息。 這可以用於 --description 和 --check。 使用多個 -v 以獲得更多冗餘信息。 |
|
| -V, --version | Print version and exit. | 打印版本並退齣。 | |
| -w, --wait | Wait if table is locked. | 等待若錶格被鎖定。 |
校驗選項
| 參數 | EN 解釋 | 中文翻譯 | 備注 |
|---|---|---|---|
| -c, --check | Check table for errors. | 檢查錶格中的錯誤。 | |
| -e, --extend-check |
Check the table VERY throughly. Only use this in extreme cases as myisamchk should normally be able to find out if the table is ok even without this switch. |
很徹底地檢查錶格。 僅在極端情況下纔使用此,myisamchk 通常應該能夠查明錶格是否 OK 即使沒有此開關。 |
|
| -F, --fast | Check only tables that haven't been closed properly. | 僅檢查尚未正確關閉的錶格。 | |
| -C, --check-only-changed | Check only tables that have changed since last check. | 僅檢查從上次檢查起有改變的錶格。 | |
| -f, --force |
Restart with '-r' if there are any errors in the table. States will be updated as with '--update-state'. |
采用 -r 重啓若錶格中有任何錯誤。 將按采用 --update-state 更新狀態。 |
|
| -i, --information | Print statistics information about table that is checked. | 打印有關檢查錶格的統計信息。 | |
| -m, --medium-check |
Faster than extend-check, but only finds 99.99% of all errors. Should be good enough for most cases. |
比 --extend-check 更快,但僅查找所有錯誤中的 99.99%。 對於大多數情況應該是夠好的。 |
|
| -U --update-state | Mark tables as crashed if you find any errors. | 將錶格標記為崩潰,若找到任何錯誤。 | |
| -T, --read-only | Don't mark table as checked. | 不將錶格標記為已校驗。 |
修復選項 (當使用 -r 或 -o)
| 參數 | EN 解釋 | 中文翻譯 | 備注 |
|---|---|---|---|
| -B, --backup | Make a backup of the .MYD file as 'filename-time.BAK'. | 將 .MYD 文件備份成 filename-time.BAK。 | |
| --correct-checksum | Correct checksum information for table. | 校正錶格的校驗和信息。 | |
| -D, --data-file-length=# | Max length of data file (when recreating data file when it's full). | 數據文件的最大長度 (當數據文件已滿時重新創建時)。 | |
| -e, --extend-check |
Try to recover every possible row from the data file, Normally this will also find a lot of garbage rows; Don't use this option if you are not totally desperate. |
試著從數據文件恢復每一可能行,通常這還會找齣很多垃圾行; 不要使用此選項,若不是完全絕望。 |
|
| -f, --force | Overwrite old temporary files. | 覆蓋舊臨時文件。 | |
| -k, --keys-used=# |
Tell MyISAM to update only some specific keys. # is a bit mask of which keys to use. This can be used to get faster inserts. |
告訴 MyISAM 僅更新某些特定鍵。 # 是要使用鍵的位掩碼。 這可以用於獲得更快插入。 |
|
| --max-record-length=# | Skip rows bigger than this if myisamchk can't allocate memory to hold it. | 跳過比這更大的行,若 myisamchk 無法分配保持它的內存。 | |
| -r, --recover | Can fix almost anything except unique keys that aren't unique. | 可以修復幾乎一切,除不是唯一的唯一鍵外。 | |
| -n, --sort-recover | Forces recovering with sorting even if the temporary file would be very big. | 按排序強製恢復,即使臨時文件很大。 | |
| -p, --parallel-recover | Uses the same technique as '-r' and '-n', but creates all the keys in parallel, in different threads. | 使用如 -r 和 -n 的相同技術,但在不同綫程並行創建所有鍵。 | |
| -o, --safe-recover |
Uses old recovery method; Slower than '-r' but can handle a couple of cases where '-r' reports that it can't fix the data file. |
使用舊恢復方法; 比 -r 更慢,但可以處理 -r 報告無法修復的幾種數據文件情況。 |
|
| --character-sets-dir=... | Directory where character sets are. | 字符集所在目錄。 | |
| --set-collation=name | Change the collation used by the index. | 更改索引使用的排序規則。 | |
| -q, --quick |
Faster repair by not modifying the data file. One can give a second '-q' to force myisamchk to modify the original datafile in case of duplicate keys. NOTE: Tables where the data file is currupted can't be fixed with this option. |
通過不修改數據文件以更快修復。 可以給齣第二 -q 以強製 myisamchk 修改原始數據文件,當有重復鍵時。 注意:采用此選項無法修復數據文件被破壞的錶格。 |
|
| -u, --unpack | Unpack file packed with myisampack. | 解包采用 myisampack 打包的文件。 |
其它動作
| 參數 | EN 解釋 | 中文翻譯 | 備注 |
|---|---|---|---|
| -a, --analyze |
Analyze distribution of keys. Will make some joins in MySQL faster. You can check the calculated distribution by using '--description --verbose table_name'. |
分析鍵分布。 將使某些 MySQL 聯結更快。 可以使用 --description --verbose table_name 校驗計算分布。 |
|
| --stats_method=name |
Specifies how index statistics collection code should treat NULLs. Possible values of name are "nulls_unequal" (default for 4.1/5.0), "nulls_equal" (emulate 4.0), and "nulls_ignored". |
指定索引統計信息收集代碼應如何處理 NULL。 名稱的可能值包括:nulls_unequal (4.1/5.0 默認)、nulls_equal (仿真 4.0) 及 nulls_ignored。 |
|
| -d, --description | Prints some information about table. | 打印有關錶格的一些信息。 | |
| -A, --set-auto-increment[=value] |
Force auto_increment to start at this or higher value. If no value is given, then sets the next auto_increment value to the highest used value for the auto key + 1. |
強製 auto_increment 從此或更高值開始。 若未給定值,將下一 auto_increment 值設為最高自動鍵使用值 + 1。 |
|
| -S, --sort-index |
Sort index blocks. This speeds up 'read-next' in applications. |
排序索引塊。 這加速應用程序 read-next。 |
|
| -R, --sort-records=# |
Sort records according to an index. This makes your data much more localized and may speed up things. (It may be VERY slow to do a sort the first time) |
根據索引排序記錄。 這使數據更本地化,並可能加速事情。 (第一次進行排序可能很慢) |
|
| -b, --block-search=# | Find a record, a block at given offset belongs to. | 查找記錄,在屬於給定偏移的塊。 |
可作為第一自變量給定的選項
| 參數 | EN 解釋 | 中文翻譯 | 備注 |
|---|---|---|---|
| --print-defaults | Print the program argument list and exit. | 打印程序自變量列錶並退齣。 | |
| --no-defaults | Don't read default options from any option file, except for login file. | 不要從任何選項文件讀取默認選項,除登錄文件外。 | |
| --defaults-file=# | Only read default options from the given file #. | 僅從給定文件 # 中讀取默認選項。 | |
| --defaults-extra-file=# | Read this file after the global files are read. | 讀取此文件,在讀取全局文件後。 | |
| --defaults-group-suffix=# | Also read groups with concat(group, suffix) | 還讀取組采用 concat(group, suffix) | |
| --login-path=# | Read this path from the login file. | 從登錄文件讀取此路徑。 |
常量
| 參數 | EN 解釋 | 中文翻譯 | 備注 |
|---|---|---|---|
| character-sets-dir | (No default value) | (無默認值) | |
| data-file-length | 0 | ||
| keys-used | 18446744073709551615 | ||
| max-record-length | 9223372036854775807 | ||
| set-auto-increment | 0 | ||
| set-collation | (No default value) | (無默認值) | |
| sort-records | 0 | ||
| tmpdir | (No default value) | (無默認值) | |
| key-buffer-size | 520192 | ||
| key-cache-block-size | 1024 | ||
| myisam-block-size | 1024 | ||
| read-buffer-size | 262136 | ||
| write-buffer-size | 262136 | ||
| sort-buffer-size | 2097144 | ||
| myisam-sort-buffer-size | 2097144 | ||
| sort-key-blocks | 16 | ||
| decode-bits | 9 | ||
| ft-min-word-len | 4 | ||
| ft-max-word-len | 84 | ||
| ft-stopword-file | (No default value) | (無默認值) | |
| stats-method | nulls_unequal |
| 功能 | 命令 | 文字解釋 | 示例 | 示例解釋 |
|---|---|---|---|---|
| 幫助 | myisamchk --help | 展示幫助信息 |
版權聲明: 本文為獨傢原創稿件,版權歸 樂數軟件 ,未經許可不得轉載。