4.6.4.1 myisamchk General Options常规选项

The options described in this section can be used for any type of table maintenance operation performed by myisamchk. 本节中描述的选项可用于myisamchk执行的任何类型的表维护操作。The sections following this one describe options that pertain only to specific operations, such as table checking or repairing.本节后面的部分描述了仅适用于特定操作的选项,如表检查或修复。

You can also set the following variables by using --var_name=value syntax:您还可以使用--var_name=value语法设置以下变量:

VariableDefault Value
decode_bits9
ft_max_word_lenversion-dependent
ft_min_word_len4
ft_stopword_filebuilt-in list
key_buffer_size523264
myisam_block_size1024
myisam_sort_key_blocks16
read_buffer_size262136
sort_buffer_size2097144
sort_key_blocks16
stats_methodnulls_unequal
write_buffer_size262136

The possible myisamchk variables and their default values can be examined with myisamchk --help:可以使用myisamchk --help检查可能的myisamchk变量及其默认值:

myisam_sort_buffer_size is used when the keys are repaired by sorting keys, which is the normal case when you use --recover. sort_buffer_size is a deprecated synonym for myisam_sort_buffer_size.myisam_sort_buffer_size用于通过排序键来修复键,这是使用--recover时的正常情况。sort_buffer_sizemyisam_sort_buffer_size的一个已弃用的同义词。

key_buffer_size is used when you are checking the table with --extend-check or when the keys are repaired by inserting keys row by row into the table (like when doing normal inserts). Repairing through the key buffer is used in the following cases:当您使用--extend-check检查表时,或者当通过逐行向表中插入键来修复键时(就像进行正常插入时一样),使用key_buffer_size。在以下情况下使用密钥缓冲区进行修复:

Repairing through the key buffer takes much less disk space than using sorting, but is also much slower.通过密钥缓冲区进行修复比使用排序需要更少的磁盘空间,但速度也慢得多。

If you want a faster repair, set the key_buffer_size and myisam_sort_buffer_size variables to about 25% of your available memory. You can set both variables to large values, because only one of them is used at a time.如果你想更快地修复,请将key_buffer_sizemyisam_sort_buffer_size变量设置为可用内存的25%左右。您可以将这两个变量都设置为较大的值,因为一次只使用其中一个。

myisam_block_size is the size used for index blocks.myisam_block_size是用于索引块的大小。

stats_method influences how NULL values are treated for index statistics collection when the --analyze option is given. stats_method会影响在给定--analyze选项时如何处理索引统计信息收集的NULL值。It acts like the myisam_stats_method system variable. For more information, see the description of myisam_stats_method in Section 5.1.8, “Server System Variables”, and Section 8.3.8, “InnoDB and MyISAM Index Statistics Collection”.它的作用类似于myisam_stats_method系统变量。有关更多信息,请参阅第5.1.8节,“服务器系统变量”第8.3.8节,“InnoDB和myisam索引统计数据收集”中对myisam_stats_method的描述。

ft_min_word_len and ft_max_word_len indicate the minimum and maximum word length for FULLTEXT indexes on MyISAM tables. ft_min_vord_lenft_max_word_len表示MyISAM表上FULLTEXT索引的最小和最大字长。ft_stopword_file names the stopword file. These need to be set under the following circumstances.ft_stopword_file命名停用词文件。这些需要在以下情况下设置。

If you use myisamchk to perform an operation that modifies table indexes (such as repair or analyze), the FULLTEXT indexes are rebuilt using the default full-text parameter values for minimum and maximum word length and the stopword file unless you specify otherwise. This can result in queries failing.如果使用myisamchk执行修改表索引的操作(如修复或分析),则除非另有指定,否则将使用最小和最大字长的默认全文参数值以及stopword文件重建FULLTEXT索引。这可能会导致查询失败。

The problem occurs because these parameters are known only by the server. They are not stored in MyISAM index files. 出现问题的原因是这些参数只有服务器知道。它们不存储在MyISAM索引文件中。To avoid the problem if you have modified the minimum or maximum word length or the stopword file in the server, specify the same ft_min_word_len, ft_max_word_len, and ft_stopword_file values to myisamchk that you use for mysqld. 为了避免在修改了服务器中的最小或最大字长或停用词文件时出现问题,请为myisamchk指定与mysqld相同的ft_min_word_lenft_max_word_lanft_stopword_file值。For example, if you have set the minimum word length to 3, you can repair a table with myisamchk like this:例如,如果你将最小字长设置为3,你可以用myisamchk修复一个表,如下所示:

myisamchk --recover --ft_min_word_len=3 tbl_name.MYI

To ensure that myisamchk and the server use the same values for full-text parameters, you can place each one in both the [mysqld] and [myisamchk] sections of an option file:为了确保myisamchk和服务器对全文参数使用相同的值,您可以将每个值放在选项文件的[mysqld][mysimchk]部分:

[mysqld]
ft_min_word_len=3

[myisamchk]
ft_min_word_len=3

An alternative to using myisamchk is to use the REPAIR TABLE, ANALYZE TABLE, OPTIMIZE TABLE, or ALTER TABLE. 使用myisamchk的另一种方法是使用REPAIR TABLEANALYZE TABLEOPTIMIZE TABLEALTER TABLEThese statements are performed by the server, which knows the proper full-text parameter values to use.这些语句由服务器执行,服务器知道要使用的正确全文参数值。