Ubuntu myisamchk 2.7 命令详解 (未集成)

描述、校验及修复 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

修正 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


myisamchk [OPTIONS] tables[.MYI]






参数 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 校验计算分布。


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 展示帮助信息


版权声明: 本文为独家原创稿件,版权归 乐数软件 ,未经许可不得转载。