~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to plugin/myisam/myisamchk.1

Removed myisamchk from what we install... there is no point for it in Drizzle.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
.\"     Title: \fBmyisamchk\fR
2
 
.\"    Author: 
3
 
.\" Generator: DocBook XSL Stylesheets v1.70.1 <http://docbook.sf.net/>
4
 
.\"      Date: 05/23/2009
5
 
.\"    Manual: MySQL Database System
6
 
.\"    Source: MySQL 6.0
7
 
.\"
8
 
.TH "\fBMYISAMCHK\fR" "1" "05/23/2009" "MySQL 6.0" "MySQL Database System"
9
 
.\" disable hyphenation
10
 
.nh
11
 
.\" disable justification (adjust text to left margin only)
12
 
.ad l
13
 
.SH "NAME"
14
 
myisamchk \- MyISAM table\-maintenance utility
15
 
.SH "SYNOPSIS"
16
 
.HP 33
17
 
\fBmyisamchk [\fR\fB\fIoptions\fR\fR\fB] \fR\fB\fItbl_name\fR\fR\fB ...\fR
18
 
.SH "DESCRIPTION"
19
 
.PP
20
 
The
21
 
\fBmyisamchk\fR
22
 
utility gets information about your database tables or checks, repairs, or optimizes them.
23
 
\fBmyisamchk\fR
24
 
works with
25
 
MyISAM
26
 
tables (tables that have
27
 
\fI.MYD\fR
28
 
and
29
 
\fI.MYI\fR
30
 
files for storing data and indexes).
31
 
.PP
32
 
The use of
33
 
\fBmyisamchk\fR
34
 
with partitioned tables is not supported.
35
 
.sp
36
 
.it 1 an-trap
37
 
.nr an-no-space-flag 1
38
 
.nr an-break-flag 1
39
 
.br
40
 
\fBCaution\fR
41
 
.PP
42
 
It is best to make a backup of a table before performing a table repair operation; under some circumstances the operation might cause data loss. Possible causes include but are not limited to file system errors.
43
 
.PP
44
 
Invoke
45
 
\fBmyisamchk\fR
46
 
like this:
47
 
.sp
48
 
.RS 3n
49
 
.nf
50
 
shell> \fBmyisamchk [\fR\fB\fIoptions\fR\fR\fB] \fR\fB\fItbl_name\fR\fR\fB ...\fR
51
 
.fi
52
 
.RE
53
 
.PP
54
 
The
55
 
\fIoptions\fR
56
 
specify what you want
57
 
\fBmyisamchk\fR
58
 
to do. They are described in the following sections. You can also get a list of options by invoking
59
 
\fBmyisamchk \-\-help\fR.
60
 
.PP
61
 
With no options,
62
 
\fBmyisamchk\fR
63
 
simply checks your table as the default operation. To get more information or to tell
64
 
\fBmyisamchk\fR
65
 
to take corrective action, specify options as described in the following discussion.
66
 
.PP
67
 
\fItbl_name\fR
68
 
is the database table you want to check or repair. If you run
69
 
\fBmyisamchk\fR
70
 
somewhere other than in the database directory, you must specify the path to the database directory, because
71
 
\fBmyisamchk\fR
72
 
has no idea where the database is located. In fact,
73
 
\fBmyisamchk\fR
74
 
does not actually care whether the files you are working on are located in a database directory. You can copy the files that correspond to a database table into some other location and perform recovery operations on them there.
75
 
.PP
76
 
You can name several tables on the
77
 
\fBmyisamchk\fR
78
 
command line if you wish. You can also specify a table by naming its index file (the file with the
79
 
\fI.MYI\fR
80
 
suffix). This allows you to specify all tables in a directory by using the pattern
81
 
\fI*.MYI\fR. For example, if you are in a database directory, you can check all the
82
 
MyISAM
83
 
tables in that directory like this:
84
 
.sp
85
 
.RS 3n
86
 
.nf
87
 
shell> \fBmyisamchk *.MYI\fR
88
 
.fi
89
 
.RE
90
 
.PP
91
 
If you are not in the database directory, you can check all the tables there by specifying the path to the directory:
92
 
.sp
93
 
.RS 3n
94
 
.nf
95
 
shell> \fBmyisamchk \fR\fB\fI/path/to/database_dir/\fR\fR\fB*.MYI\fR
96
 
.fi
97
 
.RE
98
 
.PP
99
 
You can even check all tables in all databases by specifying a wildcard with the path to the MySQL data directory:
100
 
.sp
101
 
.RS 3n
102
 
.nf
103
 
shell> \fBmyisamchk \fR\fB\fI/path/to/datadir/*/*\fR\fR\fB.MYI\fR
104
 
.fi
105
 
.RE
106
 
.PP
107
 
The recommended way to quickly check all
108
 
MyISAM
109
 
tables is:
110
 
.sp
111
 
.RS 3n
112
 
.nf
113
 
shell> \fBmyisamchk \-\-silent \-\-fast \fR\fB\fI/path/to/datadir/*/*\fR\fR\fB.MYI\fR
114
 
.fi
115
 
.RE
116
 
.PP
117
 
If you want to check all
118
 
MyISAM
119
 
tables and repair any that are corrupted, you can use the following command:
120
 
.sp
121
 
.RS 3n
122
 
.nf
123
 
shell> \fBmyisamchk \-\-silent \-\-force \-\-fast \-\-update\-state \\\fR
124
 
          \fB\-\-key_buffer_size=64M \-\-sort_buffer_size=64M \\\fR
125
 
          \fB\-\-read_buffer_size=1M \-\-write_buffer_size=1M \\\fR
126
 
          \fB\fI/path/to/datadir/*/*\fR\fR\fB.MYI\fR
127
 
.fi
128
 
.RE
129
 
.PP
130
 
This command assumes that you have more than 64MB free. For more information about memory allocation with
131
 
\fBmyisamchk\fR, see
132
 
the section called \(lq\fBMYISAMCHK\fR MEMORY USAGE\(rq.
133
 
.sp
134
 
.it 1 an-trap
135
 
.nr an-no-space-flag 1
136
 
.nr an-break-flag 1
137
 
.br
138
 
\fBImportant\fR
139
 
.PP
140
 
\fIYou must ensure that no other program is using the tables while you are running \fR\fI\fBmyisamchk\fR\fR. The most effective means of doing so is to shut down the MySQL server while running
141
 
\fBmyisamchk\fR, or to lock all tables that
142
 
\fBmyisamchk\fR
143
 
is being used on.
144
 
.PP
145
 
Otherwise, when you run
146
 
\fBmyisamchk\fR, it may display the following error message:
147
 
.sp
148
 
.RS 3n
149
 
.nf
150
 
warning: clients are using or haven't closed the table properly
151
 
.fi
152
 
.RE
153
 
.PP
154
 
This means that you are trying to check a table that has been updated by another program (such as the
155
 
\fBmysqld\fR
156
 
server) that hasn't yet closed the file or that has died without closing the file properly, which can sometimes lead to the corruption of one or more
157
 
MyISAM
158
 
tables.
159
 
.PP
160
 
If
161
 
\fBmysqld\fR
162
 
is running, you must force it to flush any table modifications that are still buffered in memory by using
163
 
FLUSH TABLES. You should then ensure that no one is using the tables while you are running
164
 
\fBmyisamchk\fR
165
 
.PP
166
 
However, the easiest way to avoid this problem is to use
167
 
CHECK TABLE
168
 
instead of
169
 
\fBmyisamchk\fR
170
 
to check tables. See
171
 
Section\ 12.5.2.2, \(lqCHECK TABLE Syntax\(rq.
172
 
.PP
173
 
\fBmyisamchk\fR
174
 
supports the options in the following table. It also reads option files and supports the options for processing them described at
175
 
Section\ 4.2.3.2.1, \(lqCommand\-Line Options that Affect Option\-File Handling\(rq.
176
 
.SH "\fBMYISAMCHK\fR GENERAL OPTIONS"
177
 
.PP
178
 
The options described in this section can be used for any type of table maintenance operation performed by
179
 
\fBmyisamchk\fR. The sections following this one describe options that pertain only to specific operations, such as table checking or repairing.
180
 
.TP 3n
181
 
\(bu
182
 
\fB\-\-help\fR,
183
 
\fB\-?\fR
184
 
.sp
185
 
Display a help message and exit. Options are grouped by type of operation.
186
 
.TP 3n
187
 
\(bu
188
 
\fB\-\-HELP\fR,
189
 
\fB\-H\fR
190
 
.sp
191
 
Display a help message and exit. Options are presented in a single list.
192
 
.TP 3n
193
 
\(bu
194
 
\fB\-\-debug=\fR\fB\fIdebug_options\fR\fR\fB, \-# \fR\fB\fIdebug_options\fR\fR
195
 
.sp
196
 
Write a debugging log. A typical
197
 
\fIdebug_options\fR
198
 
string is
199
 
\'d:t:o,\fIfile_name\fR'. The default is
200
 
\'d:t:o,/tmp/myisamchk.trace'.
201
 
.TP 3n
202
 
\(bu
203
 
\fB\-\-silent\fR,
204
 
\fB\-s\fR
205
 
.sp
206
 
Silent mode. Write output only when errors occur. You can use
207
 
\fB\-s\fR
208
 
twice (\fB\-ss\fR) to make
209
 
\fBmyisamchk\fR
210
 
very silent.
211
 
.TP 3n
212
 
\(bu
213
 
\fB\-\-verbose\fR,
214
 
\fB\-v\fR
215
 
.sp
216
 
Verbose mode. Print more information about what the program does. This can be used with
217
 
\fB\-d\fR
218
 
and
219
 
\fB\-e\fR. Use
220
 
\fB\-v\fR
221
 
multiple times (\fB\-vv\fR,
222
 
\fB\-vvv\fR) for even more output.
223
 
.TP 3n
224
 
\(bu
225
 
\fB\-\-version\fR,
226
 
\fB\-V\fR
227
 
.sp
228
 
Display version information and exit.
229
 
.TP 3n
230
 
\(bu
231
 
\fB\-\-wait\fR,
232
 
\fB\-w\fR
233
 
.sp
234
 
Instead of terminating with an error if the table is locked, wait until the table is unlocked before continuing. If you are running
235
 
\fBmysqld\fR
236
 
with external locking disabled, the table can be locked only by another
237
 
\fBmyisamchk\fR
238
 
command.
239
 
.sp
240
 
.RE
241
 
.PP
242
 
You can also set the following variables by using
243
 
\fB\-\-\fR\fB\fIvar_name\fR\fR\fB=\fR\fB\fIvalue\fR\fR
244
 
syntax:
245
 
.TS
246
 
allbox tab(:);
247
 
l l
248
 
l l
249
 
l l
250
 
l l
251
 
l l
252
 
l l
253
 
l l
254
 
l l
255
 
l l
256
 
l l
257
 
l l
258
 
l l.
259
 
T{
260
 
\fBVariable\fR
261
 
T}:T{
262
 
\fBDefault Value\fR
263
 
T}
264
 
T{
265
 
sort_key_blocks
266
 
T}:T{
267
 
16
268
 
T}
269
 
T{
270
 
stats_method
271
 
T}:T{
272
 
nulls_unequal
273
 
T}
274
 
T{
275
 
write_buffer_size
276
 
T}:T{
277
 
262136
278
 
T}
279
 
T{
280
 
decode_bits
281
 
T}:T{
282
 
9
283
 
T}
284
 
T{
285
 
ft_max_word_len
286
 
T}:T{
287
 
version\-dependent
288
 
T}
289
 
T{
290
 
ft_min_word_len
291
 
T}:T{
292
 
4
293
 
T}
294
 
T{
295
 
ft_stopword_file
296
 
T}:T{
297
 
built\-in list
298
 
T}
299
 
T{
300
 
key_buffer_size
301
 
T}:T{
302
 
523264
303
 
T}
304
 
T{
305
 
myisam_block_size
306
 
T}:T{
307
 
1024
308
 
T}
309
 
T{
310
 
read_buffer_size
311
 
T}:T{
312
 
262136
313
 
T}
314
 
T{
315
 
sort_buffer_size
316
 
T}:T{
317
 
2097144
318
 
T}
319
 
.TE
320
 
.sp
321
 
.PP
322
 
The possible
323
 
\fBmyisamchk\fR
324
 
variables and their default values can be examined with
325
 
\fBmyisamchk \-\-help\fR:
326
 
.PP
327
 
sort_buffer_size
328
 
is used when the keys are repaired by sorting keys, which is the normal case when you use
329
 
\fB\-\-recover\fR.
330
 
.PP
331
 
key_buffer_size
332
 
is used when you are checking the table with
333
 
\fB\-\-extend\-check\fR
334
 
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:
335
 
.TP 3n
336
 
\(bu
337
 
You use
338
 
\fB\-\-safe\-recover\fR.
339
 
.TP 3n
340
 
\(bu
341
 
The temporary files needed to sort the keys would be more than twice as big as when creating the key file directly. This is often the case when you have large key values for
342
 
CHAR,
343
 
VARCHAR, or
344
 
TEXT
345
 
columns, because the sort operation needs to store the complete key values as it proceeds. If you have lots of temporary space and you can force
346
 
\fBmyisamchk\fR
347
 
to repair by sorting, you can use the
348
 
\fB\-\-sort\-recover\fR
349
 
option.
350
 
.sp
351
 
.RE
352
 
.PP
353
 
Repairing through the key buffer takes much less disk space than using sorting, but is also much slower.
354
 
.PP
355
 
If you want a faster repair, set the
356
 
key_buffer_size
357
 
and
358
 
sort_buffer_size
359
 
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.
360
 
.PP
361
 
myisam_block_size
362
 
is the size used for index blocks.
363
 
.PP
364
 
stats_method
365
 
influences how
366
 
NULL
367
 
values are treated for index statistics collection when the
368
 
\fB\-\-analyze\fR
369
 
option is given. It acts like the
370
 
myisam_stats_method
371
 
system variable. For more information, see the description of
372
 
myisam_stats_method
373
 
in
374
 
Section\ 5.1.3, \(lqServer System Variables\(rq, and
375
 
Section\ 7.4.6, \(lqMyISAM Index Statistics Collection\(rq. For MySQL 6.0,
376
 
stats_method
377
 
was added in MySQL 5.0.14. For older versions, the statistics collection method is equivalent to
378
 
nulls_equal.
379
 
.PP
380
 
The
381
 
ft_min_word_len
382
 
and
383
 
ft_max_word_len
384
 
variables are available as of MySQL 4.0.0.
385
 
ft_stopword_file
386
 
is available as of MySQL 4.0.19.
387
 
.PP
388
 
ft_min_word_len
389
 
and
390
 
ft_max_word_len
391
 
indicate the minimum and maximum word length for
392
 
FULLTEXT
393
 
indexes.
394
 
ft_stopword_file
395
 
names the stopword file. These need to be set under the following circumstances.
396
 
.PP
397
 
If you use
398
 
\fBmyisamchk\fR
399
 
to perform an operation that modifies table indexes (such as repair or analyze), the
400
 
FULLTEXT
401
 
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.
402
 
.PP
403
 
The problem occurs because these parameters are known only by the server. They are not stored in
404
 
MyISAM
405
 
index files. To avoid the problem if you have modified the minimum or maximum word length or the stopword file in the server, specify the same
406
 
ft_min_word_len,
407
 
ft_max_word_len, and
408
 
ft_stopword_file
409
 
values to
410
 
\fBmyisamchk\fR
411
 
that you use for
412
 
\fBmysqld\fR. For example, if you have set the minimum word length to 3, you can repair a table with
413
 
\fBmyisamchk\fR
414
 
like this:
415
 
.sp
416
 
.RS 3n
417
 
.nf
418
 
shell> \fBmyisamchk \-\-recover \-\-ft_min_word_len=3 \fR\fB\fItbl_name\fR\fR\fB.MYI\fR
419
 
.fi
420
 
.RE
421
 
.PP
422
 
To ensure that
423
 
\fBmyisamchk\fR
424
 
and the server use the same values for full\-text parameters, you can place each one in both the
425
 
[mysqld]
426
 
and
427
 
[myisamchk]
428
 
sections of an option file:
429
 
.sp
430
 
.RS 3n
431
 
.nf
432
 
[mysqld]
433
 
ft_min_word_len=3
434
 
[myisamchk]
435
 
ft_min_word_len=3
436
 
.fi
437
 
.RE
438
 
.PP
439
 
An alternative to using
440
 
\fBmyisamchk\fR
441
 
is to use the
442
 
REPAIR TABLE,
443
 
ANALYZE TABLE,
444
 
OPTIMIZE TABLE, or
445
 
ALTER TABLE. These statements are performed by the server, which knows the proper full\-text parameter values to use.
446
 
.SH "\fBMYISAMCHK\fR CHECK OPTIONS"
447
 
.PP
448
 
\fBmyisamchk\fR
449
 
supports the following options for table checking operations:
450
 
.TP 3n
451
 
\(bu
452
 
\fB\-\-check\fR,
453
 
\fB\-c\fR
454
 
.sp
455
 
Check the table for errors. This is the default operation if you specify no option that selects an operation type explicitly.
456
 
.TP 3n
457
 
\(bu
458
 
\fB\-\-check\-only\-changed\fR,
459
 
\fB\-C\fR
460
 
.sp
461
 
Check only tables that have changed since the last check.
462
 
.TP 3n
463
 
\(bu
464
 
\fB\-\-extend\-check\fR,
465
 
\fB\-e\fR
466
 
.sp
467
 
Check the table very thoroughly. This is quite slow if the table has many indexes. This option should only be used in extreme cases. Normally,
468
 
\fBmyisamchk\fR
469
 
or
470
 
\fBmyisamchk \-\-medium\-check\fR
471
 
should be able to determine whether there are any errors in the table.
472
 
.sp
473
 
If you are using
474
 
\fB\-\-extend\-check\fR
475
 
and have plenty of memory, setting the
476
 
key_buffer_size
477
 
variable to a large value helps the repair operation run faster.
478
 
.TP 3n
479
 
\(bu
480
 
\fB\-\-fast\fR,
481
 
\fB\-F\fR
482
 
.sp
483
 
Check only tables that haven't been closed properly.
484
 
.TP 3n
485
 
\(bu
486
 
\fB\-\-force\fR,
487
 
\fB\-f\fR
488
 
.sp
489
 
Do a repair operation automatically if
490
 
\fBmyisamchk\fR
491
 
finds any errors in the table. The repair type is the same as that specified with the
492
 
\fB\-\-recover\fR
493
 
or
494
 
\fB\-r\fR
495
 
option.
496
 
.TP 3n
497
 
\(bu
498
 
\fB\-\-information\fR,
499
 
\fB\-i\fR
500
 
.sp
501
 
Print informational statistics about the table that is checked.
502
 
.TP 3n
503
 
\(bu
504
 
\fB\-\-medium\-check\fR,
505
 
\fB\-m\fR
506
 
.sp
507
 
Do a check that is faster than an
508
 
\fB\-\-extend\-check\fR
509
 
operation. This finds only 99.99% of all errors, which should be good enough in most cases.
510
 
.TP 3n
511
 
\(bu
512
 
\fB\-\-read\-only\fR,
513
 
\fB\-T\fR
514
 
.sp
515
 
Do not mark the table as checked. This is useful if you use
516
 
\fBmyisamchk\fR
517
 
to check a table that is in use by some other application that does not use locking, such as
518
 
\fBmysqld\fR
519
 
when run with external locking disabled.
520
 
.TP 3n
521
 
\(bu
522
 
\fB\-\-update\-state\fR,
523
 
\fB\-U\fR
524
 
.sp
525
 
Store information in the
526
 
\fI.MYI\fR
527
 
file to indicate when the table was checked and whether the table crashed. This should be used to get full benefit of the
528
 
\fB\-\-check\-only\-changed\fR
529
 
option, but you shouldn't use this option if the
530
 
\fBmysqld\fR
531
 
server is using the table and you are running it with external locking disabled.
532
 
.SH "\fBMYISAMCHK\fR REPAIR OPTIONS"
533
 
.PP
534
 
\fBmyisamchk\fR
535
 
supports the following options for table repair operations:
536
 
.TP 3n
537
 
\(bu
538
 
\fB\-\-backup\fR,
539
 
\fB\-B\fR
540
 
.sp
541
 
Make a backup of the
542
 
\fI.MYD\fR
543
 
file as
544
 
\fI\fIfile_name\fR\fR\fI\-\fR\fI\fItime\fR\fR\fI.BAK\fR
545
 
.TP 3n
546
 
\(bu
547
 
\fB\-\-character\-sets\-dir=\fR\fB\fIpath\fR\fR
548
 
.sp
549
 
The directory where character sets are installed. See
550
 
Section\ 9.2, \(lqThe Character Set Used for Data and Sorting\(rq.
551
 
.TP 3n
552
 
\(bu
553
 
\fB\-\-correct\-checksum\fR
554
 
.sp
555
 
Correct the checksum information for the table.
556
 
.TP 3n
557
 
\(bu
558
 
\fB\-\-data\-file\-length=\fR\fB\fIlen\fR\fR\fB, \-D \fR\fB\fIlen\fR\fR
559
 
.sp
560
 
Maximum length of the data file (when re\-creating data file when it is
561
 
\(lqfull\(rq).
562
 
.TP 3n
563
 
\(bu
564
 
\fB\-\-extend\-check\fR,
565
 
\fB\-e\fR
566
 
.sp
567
 
Do a repair that tries to recover every possible row from the data file. Normally, this also finds a lot of garbage rows. Do not use this option unless you are desperate.
568
 
.TP 3n
569
 
\(bu
570
 
\fB\-\-force\fR,
571
 
\fB\-f\fR
572
 
.sp
573
 
Overwrite old intermediate files (files with names like
574
 
\fI\fItbl_name\fR\fR\fI.TMD\fR) instead of aborting.
575
 
.TP 3n
576
 
\(bu
577
 
\fB\-\-keys\-used=\fR\fB\fIval\fR\fR,
578
 
\fB\-k \fR\fB\fIval\fR\fR
579
 
.sp
580
 
For
581
 
\fBmyisamchk\fR, the option value is a bit\-value that indicates which indexes to update. Each binary bit of the option value corresponds to a table index, where the first index is bit 0. An option value of 0 disables updates to all indexes, which can be used to get faster inserts. Deactivated indexes can be reactivated by using
582
 
\fBmyisamchk \-r\fR.
583
 
.TP 3n
584
 
\(bu
585
 
\fB\-\-no\-symlinks\fR,
586
 
\fB\-l\fR
587
 
.sp
588
 
Do not follow symbolic links. Normally
589
 
\fBmyisamchk\fR
590
 
repairs the table that a symlink points to. This option does not exist as of MySQL 4.0 because versions from 4.0 on do not remove symlinks during repair operations.
591
 
.TP 3n
592
 
\(bu
593
 
\fB\-\-max\-record\-length=\fR\fB\fIlen\fR\fR
594
 
.sp
595
 
Skip rows larger than the given length if
596
 
\fBmyisamchk\fR
597
 
cannot allocate memory to hold them.
598
 
.TP 3n
599
 
\(bu
600
 
\fB\-\-parallel\-recover\fR,
601
 
\fB\-p\fR
602
 
.sp
603
 
Uses the same technique as
604
 
\fB\-r\fR
605
 
and
606
 
\fB\-n\fR, but creates all the keys in parallel, using different threads.
607
 
\fIThis is beta\-quality code. Use at your own risk!\fR
608
 
.TP 3n
609
 
\(bu
610
 
\fB\-\-quick\fR,
611
 
\fB\-q\fR
612
 
.sp
613
 
Achieve a faster repair by not modifying the data file. You can specify this option twice to force
614
 
\fBmyisamchk\fR
615
 
to modify the original data file in case of duplicate keys.
616
 
.TP 3n
617
 
\(bu
618
 
\fB\-\-recover\fR,
619
 
\fB\-r\fR
620
 
.sp
621
 
Do a repair that can fix almost any problem except unique keys that are not unique (which is an extremely unlikely error with
622
 
MyISAM
623
 
tables). If you want to recover a table, this is the option to try first. You should try
624
 
\fB\-\-safe\-recover\fR
625
 
only if
626
 
\fBmyisamchk\fR
627
 
reports that the table cannot be recovered using
628
 
\fB\-\-recover\fR. (In the unlikely case that
629
 
\fB\-\-recover\fR
630
 
fails, the data file remains intact.)
631
 
.sp
632
 
If you have lots of memory, you should increase the value of
633
 
sort_buffer_size.
634
 
.TP 3n
635
 
\(bu
636
 
\fB\-\-safe\-recover\fR,
637
 
\fB\-o\fR
638
 
.sp
639
 
Do a repair using an old recovery method that reads through all rows in order and updates all index trees based on the rows found. This is an order of magnitude slower than
640
 
\fB\-\-recover\fR, but can handle a couple of very unlikely cases that
641
 
\fB\-\-recover\fR
642
 
cannot. This recovery method also uses much less disk space than
643
 
\fB\-\-recover\fR. Normally, you should repair first using
644
 
\fB\-\-recover\fR, and then with
645
 
\fB\-\-safe\-recover\fR
646
 
only if
647
 
\fB\-\-recover\fR
648
 
fails.
649
 
.sp
650
 
If you have lots of memory, you should increase the value of
651
 
key_buffer_size.
652
 
.TP 3n
653
 
\(bu
654
 
\fB\-\-set\-character\-set=\fR\fB\fIname\fR\fR
655
 
.sp
656
 
Change the character set used by the table indexes. This option was replaced by
657
 
\fB\-\-set\-collation\fR
658
 
in MySQL 5.0.3.
659
 
.TP 3n
660
 
\(bu
661
 
\fB\-\-set\-collation=\fR\fB\fIname\fR\fR
662
 
.sp
663
 
Specify the collation to use for sorting table indexes. The character set name is implied by the first part of the collation name.
664
 
.TP 3n
665
 
\(bu
666
 
\fB\-\-sort\-recover\fR,
667
 
\fB\-n\fR
668
 
.sp
669
 
Force
670
 
\fBmyisamchk\fR
671
 
to use sorting to resolve the keys even if the temporary files would be very large.
672
 
.TP 3n
673
 
\(bu
674
 
\fB\-\-tmpdir=\fR\fB\fIpath\fR\fR,
675
 
\fB\-t \fR\fB\fIpath\fR\fR
676
 
.sp
677
 
Path of the directory to be used for storing temporary files. If this is not set,
678
 
\fBmyisamchk\fR
679
 
uses the value of the
680
 
TMPDIR
681
 
environment variable.
682
 
tmpdir
683
 
can be set to a list of directory paths that are used successively in round\-robin fashion for creating temporary files. The separator character between directory names is the colon (\(lq:\(rq) on Unix and the semicolon (\(lq;\(rq) on Windows, NetWare, and OS/2.
684
 
.TP 3n
685
 
\(bu
686
 
\fB\-\-unpack\fR,
687
 
\fB\-u\fR
688
 
.sp
689
 
Unpack a table that was packed with
690
 
\fBmyisampack\fR.
691
 
.SH "OTHER MYISAMCHK OPTIONS"
692
 
.PP
693
 
\fBmyisamchk\fR
694
 
supports the following options for actions other than table checks and repairs:
695
 
.TP 3n
696
 
\(bu
697
 
\fB\-\-analyze\fR,
698
 
\fB\-a\fR
699
 
.sp
700
 
Analyze the distribution of key values. This improves join performance by enabling the join optimizer to better choose the order in which to join the tables and which indexes it should use. To obtain information about the key distribution, use a
701
 
\fBmyisamchk \-\-description \-\-verbose \fR\fB\fItbl_name\fR\fR
702
 
command or the
703
 
SHOW INDEX FROM \fItbl_name\fR
704
 
statement.
705
 
.TP 3n
706
 
\(bu
707
 
\fB\-\-block\-search=\fR\fB\fIoffset\fR\fR,
708
 
\fB\-b \fR\fB\fIoffset\fR\fR
709
 
.sp
710
 
Find the record that a block at the given offset belongs to.
711
 
.TP 3n
712
 
\(bu
713
 
\fB\-\-description\fR,
714
 
\fB\-d\fR
715
 
.sp
716
 
Print some descriptive information about the table.
717
 
.TP 3n
718
 
\(bu
719
 
\fB\-\-set\-auto\-increment[=\fR\fB\fIvalue\fR\fR\fB]\fR,
720
 
\fB\-A[\fR\fB\fIvalue\fR\fR\fB]\fR
721
 
.sp
722
 
Force
723
 
AUTO_INCREMENT
724
 
numbering for new records to start at the given value (or higher, if there are existing records with
725
 
AUTO_INCREMENT
726
 
values this large). If
727
 
\fIvalue\fR
728
 
is not specified,
729
 
AUTO_INCREMENT
730
 
numbers for new records begin with the largest value currently in the table, plus one.
731
 
.TP 3n
732
 
\(bu
733
 
\fB\-\-sort\-index\fR,
734
 
\fB\-S\fR
735
 
.sp
736
 
Sort the index tree blocks in high\-low order. This optimizes seeks and makes table scans that use indexes faster.
737
 
.TP 3n
738
 
\(bu
739
 
\fB\-\-sort\-records=\fR\fB\fIN\fR\fR,
740
 
\fB\-R \fR\fB\fIN\fR\fR
741
 
.sp
742
 
Sort records according to a particular index. This makes your data much more localized and may speed up range\-based
743
 
SELECT
744
 
and
745
 
ORDER BY
746
 
operations that use this index. (The first time you use this option to sort a table, it may be very slow.) To determine a table's index numbers, use
747
 
SHOW INDEX, which displays a table's indexes in the same order that
748
 
\fBmyisamchk\fR
749
 
sees them. Indexes are numbered beginning with 1.
750
 
.sp
751
 
If keys are not packed (PACK_KEYS=0), they have the same length, so when
752
 
\fBmyisamchk\fR
753
 
sorts and moves records, it just overwrites record offsets in the index. If keys are packed (PACK_KEYS=1),
754
 
\fBmyisamchk\fR
755
 
must unpack key blocks first, then re\-create indexes and pack the key blocks again. (In this case, re\-creating indexes is faster than updating offsets for each index.)
756
 
.SH "\fBMYISAMCHK\fR MEMORY USAGE"
757
 
.PP
758
 
Memory allocation is important when you run
759
 
\fBmyisamchk\fR.
760
 
\fBmyisamchk\fR
761
 
uses no more memory than its memory\-related variables are set to. If you are going to use
762
 
\fBmyisamchk\fR
763
 
on very large tables, you should first decide how much memory you want it to use. The default is to use only about 3MB to perform repairs. By using larger values, you can get
764
 
\fBmyisamchk\fR
765
 
to operate faster. For example, if you have more than 32MB RAM, you could use options such as these (in addition to any other options you might specify):
766
 
.sp
767
 
.RS 3n
768
 
.nf
769
 
shell> \fBmyisamchk \-\-sort_buffer_size=16M \-\-key_buffer_size=16M \\\fR
770
 
           \fB\-\-read_buffer_size=1M \-\-write_buffer_size=1M ...\fR
771
 
.fi
772
 
.RE
773
 
.PP
774
 
Using
775
 
\fB\-\-sort_buffer_size=16M\fR
776
 
should probably be enough for most cases.
777
 
.PP
778
 
Be aware that
779
 
\fBmyisamchk\fR
780
 
uses temporary files in
781
 
TMPDIR. If
782
 
TMPDIR
783
 
points to a memory file system, you may easily get out of memory errors. If this happens, run
784
 
\fBmyisamchk\fR
785
 
with the
786
 
\fB\-\-tmpdir=\fR\fB\fIpath\fR\fR
787
 
option to specify some directory located on a file system that has more space.
788
 
.PP
789
 
When repairing,
790
 
\fBmyisamchk\fR
791
 
also needs a lot of disk space:
792
 
.TP 3n
793
 
\(bu
794
 
Double the size of the data file (the original file and a copy). This space is not needed if you do a repair with
795
 
\fB\-\-quick\fR; in this case, only the index file is re\-created.
796
 
\fIThis space must be available on the same file system as the original data file\fR, as the copy is created in the same directory as the original.
797
 
.TP 3n
798
 
\(bu
799
 
Space for the new index file that replaces the old one. The old index file is truncated at the start of the repair operation, so you usually ignore this space. This space must be available on the same file system as the original data file.
800
 
.TP 3n
801
 
\(bu
802
 
When using
803
 
\fB\-\-recover\fR
804
 
or
805
 
\fB\-\-sort\-recover\fR
806
 
(but not when using
807
 
\fB\-\-safe\-recover\fR), you need space for a sort buffer. The following formula yields the amount of space required:
808
 
.sp
809
 
.RS 3n
810
 
.nf
811
 
(\fIlargest_key\fR + \fIrow_pointer_length\fR) \(mu \fInumber_of_rows\fR \(mu 2
812
 
.fi
813
 
.RE
814
 
You can check the length of the keys and the
815
 
row_pointer_length
816
 
with
817
 
\fBmyisamchk \-dv \fR\fB\fItbl_name\fR\fR. This space is allocated in the temporary directory (specified by
818
 
TMPDIR
819
 
or
820
 
\fB\-\-tmpdir=\fR\fB\fIpath\fR\fR).
821
 
.sp
822
 
.RE
823
 
.PP
824
 
If you have a problem with disk space during repair, you can try
825
 
\fB\-\-safe\-recover\fR
826
 
instead of
827
 
\fB\-\-recover\fR.
828
 
.SH "COPYRIGHT"
829
 
.PP
830
 
Copyright 2007\-2008 MySQL AB, 2009 Sun Microsystems, Inc.
831
 
.PP
832
 
This documentation is free software; you can redistribute it and/or modify it only under the terms of the GNU General Public License as published by the Free Software Foundation; version 2 of the License.
833
 
.PP
834
 
This documentation is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
835
 
.PP
836
 
You should have received a copy of the GNU General Public License along with the program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110\-1301 USA or see http://www.gnu.org/licenses/.
837
 
.SH "SEE ALSO"
838
 
For more information, please refer to the MySQL Reference Manual,
839
 
which may already be installed locally and which is also available
840
 
online at http://dev.mysql.com/doc/.
841
 
.SH AUTHOR
842
 
Sun Microsystems, Inc. (http://www.mysql.com/).