1MYISAMCHK(1) MySQL Database System MYISAMCHK(1)
2
3
4
6 myisamchk - MyISAM table-maintenance utility
7
9 myisamchk [options] tbl_name ...
10
12 The myisamchk utility gets information about your database tables or
13 checks, repairs, or optimizes them. myisamchk works with MyISAM tables
14 (tables that have .MYD and .MYI files for storing data and indexes).
15
16 You can also use the CHECK TABLE and REPAIR TABLE statements to check
17 and repair MyISAM tables. See Section 13.7.3.2, “CHECK TABLE
18 Statement”, and Section 13.7.3.5, “REPAIR TABLE Statement”.
19
20 The use of myisamchk with partitioned tables is not supported.
21
22 Caution
23 It is best to make a backup of a table before performing a table
24 repair operation; under some circumstances the operation might
25 cause data loss. Possible causes include but are not limited to
26 file system errors.
27
28 Invoke myisamchk like this:
29
30 shell> myisamchk [options] tbl_name ...
31
32 The options specify what you want myisamchk to do. They are described
33 in the following sections. You can also get a list of options by
34 invoking myisamchk --help.
35
36 With no options, myisamchk simply checks your table as the default
37 operation. To get more information or to tell myisamchk to take
38 corrective action, specify options as described in the following
39 discussion.
40
41 tbl_name is the database table you want to check or repair. If you run
42 myisamchk somewhere other than in the database directory, you must
43 specify the path to the database directory, because myisamchk has no
44 idea where the database is located. In fact, myisamchk does not
45 actually care whether the files you are working on are located in a
46 database directory. You can copy the files that correspond to a
47 database table into some other location and perform recovery operations
48 on them there.
49
50 You can name several tables on the myisamchk command line if you wish.
51 You can also specify a table by naming its index file (the file with
52 the .MYI suffix). This enables you to specify all tables in a directory
53 by using the pattern *.MYI. For example, if you are in a database
54 directory, you can check all the MyISAM tables in that directory like
55 this:
56
57 shell> myisamchk *.MYI
58
59 If you are not in the database directory, you can check all the tables
60 there by specifying the path to the directory:
61
62 shell> myisamchk /path/to/database_dir/*.MYI
63
64 You can even check all tables in all databases by specifying a wildcard
65 with the path to the MySQL data directory:
66
67 shell> myisamchk /path/to/datadir/*/*.MYI
68
69 The recommended way to quickly check all MyISAM tables is:
70
71 shell> myisamchk --silent --fast /path/to/datadir/*/*.MYI
72
73 If you want to check all MyISAM tables and repair any that are
74 corrupted, you can use the following command:
75
76 shell> myisamchk --silent --force --fast --update-state \
77 --key_buffer_size=64M --myisam_sort_buffer_size=64M \
78 --read_buffer_size=1M --write_buffer_size=1M \
79 /path/to/datadir/*/*.MYI
80
81 This command assumes that you have more than 64MB free. For more
82 information about memory allocation with myisamchk, see the section
83 called “MYISAMCHK MEMORY USAGE”.
84
85 For additional information about using myisamchk, see Section 7.6,
86 “MyISAM Table Maintenance and Crash Recovery”.
87
88 Important
89 You must ensure that no other program is using the tables while you
90 are running myisamchk. The most effective means of doing so is to
91 shut down the MySQL server while running myisamchk, or to lock all
92 tables that myisamchk is being used on.
93
94 Otherwise, when you run myisamchk, it may display the following
95 error message:
96
97 warning: clients are using or haven't closed the table properly
98
99 This means that you are trying to check a table that has been
100 updated by another program (such as the mysqld server) that hasn't
101 yet closed the file or that has died without closing the file
102 properly, which can sometimes lead to the corruption of one or more
103 MyISAM tables.
104
105 If mysqld is running, you must force it to flush any table
106 modifications that are still buffered in memory by using FLUSH
107 TABLES. You should then ensure that no one is using the tables
108 while you are running myisamchk
109
110 However, the easiest way to avoid this problem is to use CHECK
111 TABLE instead of myisamchk to check tables. See Section 13.7.3.2,
112 “CHECK TABLE Statement”.
113
114 myisamchk supports the following options, which can be specified on the
115 command line or in the [myisamchk] group of an option file. For
116 information about option files used by MySQL programs, see
117 Section 4.2.2.2, “Using Option Files”.
118
120 The options described in this section can be used for any type of table
121 maintenance operation performed by myisamchk. The sections following
122 this one describe options that pertain only to specific operations,
123 such as table checking or repairing.
124
125 · --help, -?
126
127 Display a help message and exit. Options are grouped by type of
128 operation.
129
130 · --HELP, -H
131
132 Display a help message and exit. Options are presented in a single
133 list.
134
135 · --debug=debug_options, -# debug_options
136
137 Write a debugging log. A typical debug_options string is
138 d:t:o,file_name. The default is d:t:o,/tmp/myisamchk.trace.
139
140 This option is available only if MySQL was built using WITH_DEBUG.
141 MySQL release binaries provided by Oracle are not built using this
142 option.
143
144 · --defaults-extra-file=file_name
145
146 Read this option file after the global option file but (on Unix)
147 before the user option file. If the file does not exist or is
148 otherwise inaccessible, an error occurs. file_name is interpreted
149 relative to the current directory if given as a relative path name
150 rather than a full path name.
151
152 For additional information about this and other option-file
153 options, see Section 4.2.2.3, “Command-Line Options that Affect
154 Option-File Handling”.
155
156 · --defaults-file=file_name
157
158 Use only the given option file. If the file does not exist or is
159 otherwise inaccessible, an error occurs. file_name is interpreted
160 relative to the current directory if given as a relative path name
161 rather than a full path name.
162
163 For additional information about this and other option-file
164 options, see Section 4.2.2.3, “Command-Line Options that Affect
165 Option-File Handling”.
166
167 · --defaults-group-suffix=str
168
169 Read not only the usual option groups, but also groups with the
170 usual names and a suffix of str. For example, myisamchk normally
171 reads the [myisamchk] group. If the --defaults-group-suffix=_other
172 option is given, myisamchk also reads the [myisamchk_other] group.
173
174 For additional information about this and other option-file
175 options, see Section 4.2.2.3, “Command-Line Options that Affect
176 Option-File Handling”.
177
178 · --no-defaults
179
180 Do not read any option files. If program startup fails due to
181 reading unknown options from an option file, --no-defaults can be
182 used to prevent them from being read.
183
184 The exception is that the .mylogin.cnf file, if it exists, is read
185 in all cases. This permits passwords to be specified in a safer way
186 than on the command line even when --no-defaults is used.
187 (.mylogin.cnf is created by the mysql_config_editor utility. See
188 mysql_config_editor(1).)
189
190 For additional information about this and other option-file
191 options, see Section 4.2.2.3, “Command-Line Options that Affect
192 Option-File Handling”.
193
194 · --print-defaults
195
196 Print the program name and all options that it gets from option
197 files.
198
199 For additional information about this and other option-file
200 options, see Section 4.2.2.3, “Command-Line Options that Affect
201 Option-File Handling”.
202
203 · --silent, -s
204
205 Silent mode. Write output only when errors occur. You can use -s
206 twice (-ss) to make myisamchk very silent.
207
208 · --verbose, -v
209
210 Verbose mode. Print more information about what the program does.
211 This can be used with -d and -e. Use -v multiple times (-vv, -vvv)
212 for even more output.
213
214 · --version, -V
215
216 Display version information and exit.
217
218 · --wait, -w
219
220 Instead of terminating with an error if the table is locked, wait
221 until the table is unlocked before continuing. If you are running
222 mysqld with external locking disabled, the table can be locked only
223 by another myisamchk command.
224
225 You can also set the following variables by using --var_name=value
226 syntax:
227
228 ┌───────────────────────┬───────────────────┐
229 │Variable │ Default Value │
230 ├───────────────────────┼───────────────────┤
231 │decode_bits │ 9 │
232 ├───────────────────────┼───────────────────┤
233 │ft_max_word_len │ version-dependent │
234 ├───────────────────────┼───────────────────┤
235 │ft_min_word_len │ 4 │
236 ├───────────────────────┼───────────────────┤
237 │ft_stopword_file │ built-in list │
238 ├───────────────────────┼───────────────────┤
239 │key_buffer_size │ 523264 │
240 ├───────────────────────┼───────────────────┤
241 │myisam_block_size │ 1024 │
242 ├───────────────────────┼───────────────────┤
243 │myisam_sort_key_blocks │ 16 │
244 ├───────────────────────┼───────────────────┤
245 │read_buffer_size │ 262136 │
246 ├───────────────────────┼───────────────────┤
247 │sort_buffer_size │ 2097144 │
248 ├───────────────────────┼───────────────────┤
249 │sort_key_blocks │ 16 │
250 ├───────────────────────┼───────────────────┤
251 │stats_method │ nulls_unequal │
252 ├───────────────────────┼───────────────────┤
253 │write_buffer_size │ 262136 │
254 └───────────────────────┴───────────────────┘
255
256 The possible myisamchk variables and their default values can be
257 examined with myisamchk --help:
258
259 myisam_sort_buffer_size is used when the keys are repaired by sorting
260 keys, which is the normal case when you use --recover.
261 sort_buffer_size is a deprecated synonym for myisam_sort_buffer_size.
262
263 key_buffer_size is used when you are checking the table with
264 --extend-check or when the keys are repaired by inserting keys row by
265 row into the table (like when doing normal inserts). Repairing through
266 the key buffer is used in the following cases:
267
268 · You use --safe-recover.
269
270 · The temporary files needed to sort the keys would be more than
271 twice as big as when creating the key file directly. This is often
272 the case when you have large key values for CHAR, VARCHAR, or TEXT
273 columns, because the sort operation needs to store the complete key
274 values as it proceeds. If you have lots of temporary space and you
275 can force myisamchk to repair by sorting, you can use the
276 --sort-recover option.
277
278 Repairing through the key buffer takes much less disk space than using
279 sorting, but is also much slower.
280
281 If you want a faster repair, set the key_buffer_size and
282 myisam_sort_buffer_size variables to about 25% of your available
283 memory. You can set both variables to large values, because only one of
284 them is used at a time.
285
286 myisam_block_size is the size used for index blocks.
287
288 stats_method influences how NULL values are treated for index
289 statistics collection when the --analyze option is given. It acts like
290 the myisam_stats_method system variable. For more information, see the
291 description of myisam_stats_method in Section 5.1.8, “Server System
292 Variables”, and Section 8.3.8, “InnoDB and MyISAM Index Statistics
293 Collection”.
294
295 ft_min_word_len and ft_max_word_len indicate the minimum and maximum
296 word length for FULLTEXT indexes on MyISAM tables. ft_stopword_file
297 names the stopword file. These need to be set under the following
298 circumstances.
299
300 If you use myisamchk to perform an operation that modifies table
301 indexes (such as repair or analyze), the FULLTEXT indexes are rebuilt
302 using the default full-text parameter values for minimum and maximum
303 word length and the stopword file unless you specify otherwise. This
304 can result in queries failing.
305
306 The problem occurs because these parameters are known only by the
307 server. They are not stored in MyISAM index files. To avoid the problem
308 if you have modified the minimum or maximum word length or the stopword
309 file in the server, specify the same ft_min_word_len, ft_max_word_len,
310 and ft_stopword_file values to myisamchk that you use for mysqld. For
311 example, if you have set the minimum word length to 3, you can repair a
312 table with myisamchk like this:
313
314 shell> myisamchk --recover --ft_min_word_len=3 tbl_name.MYI
315
316 To ensure that myisamchk and the server use the same values for
317 full-text parameters, you can place each one in both the [mysqld] and
318 [myisamchk] sections of an option file:
319
320 [mysqld]
321 ft_min_word_len=3
322 [myisamchk]
323 ft_min_word_len=3
324
325 An alternative to using myisamchk is to use the REPAIR TABLE, ANALYZE
326 TABLE, OPTIMIZE TABLE, or ALTER TABLE. These statements are performed
327 by the server, which knows the proper full-text parameter values to
328 use.
329
331 myisamchk supports the following options for table checking operations:
332
333 · --check, -c
334
335 Check the table for errors. This is the default operation if you
336 specify no option that selects an operation type explicitly.
337
338 · --check-only-changed, -C
339
340 Check only tables that have changed since the last check.
341
342 · --extend-check, -e
343
344 Check the table very thoroughly. This is quite slow if the table
345 has many indexes. This option should only be used in extreme cases.
346 Normally, myisamchk or myisamchk --medium-check should be able to
347 determine whether there are any errors in the table.
348
349 If you are using --extend-check and have plenty of memory, setting
350 the key_buffer_size variable to a large value helps the repair
351 operation run faster.
352
353 See also the description of this option under table repair options.
354
355 For a description of the output format, see the section called
356 “OBTAINING TABLE INFORMATION WITH MYISAMCHK”.
357
358 · --fast, -F
359
360 Check only tables that haven't been closed properly.
361
362 · --force, -f
363
364 Do a repair operation automatically if myisamchk finds any errors
365 in the table. The repair type is the same as that specified with
366 the --recover or -r option.
367
368 · --information, -i
369
370 Print informational statistics about the table that is checked.
371
372 · --medium-check, -m
373
374 Do a check that is faster than an --extend-check operation. This
375 finds only 99.99% of all errors, which should be good enough in
376 most cases.
377
378 · --read-only, -T
379
380 Do not mark the table as checked. This is useful if you use
381 myisamchk to check a table that is in use by some other application
382 that does not use locking, such as mysqld when run with external
383 locking disabled.
384
385 · --update-state, -U
386
387 Store information in the .MYI file to indicate when the table was
388 checked and whether the table crashed. This should be used to get
389 full benefit of the --check-only-changed option, but you shouldn't
390 use this option if the mysqld server is using the table and you are
391 running it with external locking disabled.
392
394 myisamchk supports the following options for table repair operations
395 (operations performed when an option such as --recover or
396 --safe-recover is given):
397
398 · --backup, -B
399
400 Make a backup of the .MYD file as file_name-time.BAK
401
402 · --character-sets-dir=dir_name
403
404 The directory where character sets are installed. See
405 Section 10.15, “Character Set Configuration”.
406
407 · --correct-checksum
408
409 Correct the checksum information for the table.
410
411 · --data-file-length=len, -D len
412
413 The maximum length of the data file (when re-creating data file
414 when it is “full”).
415
416 · --extend-check, -e
417
418 Do a repair that tries to recover every possible row from the data
419 file. Normally, this also finds a lot of garbage rows. Do not use
420 this option unless you are desperate.
421
422 See also the description of this option under table checking
423 options.
424
425 For a description of the output format, see the section called
426 “OBTAINING TABLE INFORMATION WITH MYISAMCHK”.
427
428 · --force, -f
429
430 Overwrite old intermediate files (files with names like
431 tbl_name.TMD) instead of aborting.
432
433 · --keys-used=val, -k val
434
435 For myisamchk, the option value is a bit value that indicates which
436 indexes to update. Each binary bit of the option value corresponds
437 to a table index, where the first index is bit 0. An option value
438 of 0 disables updates to all indexes, which can be used to get
439 faster inserts. Deactivated indexes can be reactivated by using
440 myisamchk -r.
441
442 · --no-symlinks, -l
443
444 Do not follow symbolic links. Normally myisamchk repairs the table
445 that a symlink points to. This option does not exist as of MySQL
446 4.0 because versions from 4.0 on do not remove symlinks during
447 repair operations.
448
449 · --max-record-length=len
450
451 Skip rows larger than the given length if myisamchk cannot allocate
452 memory to hold them.
453
454 · --parallel-recover, -p
455
456 Use the same technique as -r and -n, but create all the keys in
457 parallel, using different threads. This is beta-quality code. Use
458 at your own risk!
459
460 · --quick, -q
461
462 Achieve a faster repair by modifying only the index file, not the
463 data file. You can specify this option twice to force myisamchk to
464 modify the original data file in case of duplicate keys.
465
466 · --recover, -r
467
468 Do a repair that can fix almost any problem except unique keys that
469 are not unique (which is an extremely unlikely error with MyISAM
470 tables). If you want to recover a table, this is the option to try
471 first. You should try --safe-recover only if myisamchk reports that
472 the table cannot be recovered using --recover. (In the unlikely
473 case that --recover fails, the data file remains intact.)
474
475 If you have lots of memory, you should increase the value of
476 myisam_sort_buffer_size.
477
478 · --safe-recover, -o
479
480 Do a repair using an old recovery method that reads through all
481 rows in order and updates all index trees based on the rows found.
482 This is an order of magnitude slower than --recover, but can handle
483 a couple of very unlikely cases that --recover cannot. This
484 recovery method also uses much less disk space than --recover.
485 Normally, you should repair first using --recover, and then with
486 --safe-recover only if --recover fails.
487
488 If you have lots of memory, you should increase the value of
489 key_buffer_size.
490
491 · --set-collation=name
492
493 Specify the collation to use for sorting table indexes. The
494 character set name is implied by the first part of the collation
495 name.
496
497 · --sort-recover, -n
498
499 Force myisamchk to use sorting to resolve the keys even if the
500 temporary files would be very large.
501
502 · --tmpdir=dir_name, -t dir_name
503
504 The path of the directory to be used for storing temporary files.
505 If this is not set, myisamchk uses the value of the TMPDIR
506 environment variable. --tmpdir can be set to a list of directory
507 paths that are used successively in round-robin fashion for
508 creating temporary files. The separator character between directory
509 names is the colon (:) on Unix and the semicolon (;) on Windows.
510
511 · --unpack, -u
512
513 Unpack a table that was packed with myisampack.
514
516 myisamchk supports the following options for actions other than table
517 checks and repairs:
518
519 · --analyze, -a
520
521 Analyze the distribution of key values. This improves join
522 performance by enabling the join optimizer to better choose the
523 order in which to join the tables and which indexes it should use.
524 To obtain information about the key distribution, use a myisamchk
525 --description --verbose tbl_name command or the SHOW INDEX FROM
526 tbl_name statement.
527
528 · --block-search=offset, -b offset
529
530 Find the record that a block at the given offset belongs to.
531
532 · --description, -d
533
534 Print some descriptive information about the table. Specifying the
535 --verbose option once or twice produces additional information. See
536 the section called “OBTAINING TABLE INFORMATION WITH MYISAMCHK”.
537
538 · --set-auto-increment[=value], -A[value]
539
540 Force AUTO_INCREMENT numbering for new records to start at the
541 given value (or higher, if there are existing records with
542 AUTO_INCREMENT values this large). If value is not specified,
543 AUTO_INCREMENT numbers for new records begin with the largest value
544 currently in the table, plus one.
545
546 · --sort-index, -S
547
548 Sort the index tree blocks in high-low order. This optimizes seeks
549 and makes table scans that use indexes faster.
550
551 · --sort-records=N, -R N
552
553 Sort records according to a particular index. This makes your data
554 much more localized and may speed up range-based SELECT and ORDER
555 BY operations that use this index. (The first time you use this
556 option to sort a table, it may be very slow.) To determine a
557 table's index numbers, use SHOW INDEX, which displays a table's
558 indexes in the same order that myisamchk sees them. Indexes are
559 numbered beginning with 1.
560
561 If keys are not packed (PACK_KEYS=0), they have the same length, so
562 when myisamchk sorts and moves records, it just overwrites record
563 offsets in the index. If keys are packed (PACK_KEYS=1), myisamchk
564 must unpack key blocks first, then re-create indexes and pack the
565 key blocks again. (In this case, re-creating indexes is faster than
566 updating offsets for each index.)
567
569 To obtain a description of a MyISAM table or statistics about it, use
570 the commands shown here. The output from these commands is explained
571 later in this section.
572
573 · myisamchk -d tbl_name
574
575 Runs myisamchk in “describe mode” to produce a description of your
576 table. If you start the MySQL server with external locking
577 disabled, myisamchk may report an error for a table that is updated
578 while it runs. However, because myisamchk does not change the table
579 in describe mode, there is no risk of destroying data.
580
581 · myisamchk -dv tbl_name
582
583 Adding -v runs myisamchk in verbose mode so that it produces more
584 information about the table. Adding -v a second time produces even
585 more information.
586
587 · myisamchk -eis tbl_name
588
589 Shows only the most important information from a table. This
590 operation is slow because it must read the entire table.
591
592 · myisamchk -eiv tbl_name
593
594 This is like -eis, but tells you what is being done.
595
596 The tbl_name argument can be either the name of a MyISAM table or the
597 name of its index file, as described in myisamchk(1). Multiple tbl_name
598 arguments can be given.
599
600 Suppose that a table named person has the following structure. (The
601 MAX_ROWS table option is included so that in the example output from
602 myisamchk shown later, some values are smaller and fit the output
603 format more easily.)
604
605 CREATE TABLE person
606 (
607 id INT NOT NULL AUTO_INCREMENT,
608 last_name VARCHAR(20) NOT NULL,
609 first_name VARCHAR(20) NOT NULL,
610 birth DATE,
611 death DATE,
612 PRIMARY KEY (id),
613 INDEX (last_name, first_name),
614 INDEX (birth)
615 ) MAX_ROWS = 1000000 ENGINE=MYISAM;
616
617 Suppose also that the table has these data and index file sizes:
618
619 -rw-rw---- 1 mysql mysql 9347072 Aug 19 11:47 person.MYD
620 -rw-rw---- 1 mysql mysql 6066176 Aug 19 11:47 person.MYI
621
622 Example of myisamchk -dvv output:
623
624 MyISAM file: person
625 Record format: Packed
626 Character set: utf8mb4_0900_ai_ci (255)
627 File-version: 1
628 Creation time: 2017-03-30 21:21:30
629 Status: checked,analyzed,optimized keys,sorted index pages
630 Auto increment key: 1 Last value: 306688
631 Data records: 306688 Deleted blocks: 0
632 Datafile parts: 306688 Deleted data: 0
633 Datafile pointer (bytes): 4 Keyfile pointer (bytes): 3
634 Datafile length: 9347072 Keyfile length: 6066176
635 Max datafile length: 4294967294 Max keyfile length: 17179868159
636 Recordlength: 54
637 table description:
638 Key Start Len Index Type Rec/key Root Blocksize
639 1 2 4 unique long 1 1024
640 2 6 80 multip. varchar prefix 0 1024
641 87 80 varchar 0
642 3 168 3 multip. uint24 NULL 0 1024
643 Field Start Length Nullpos Nullbit Type
644 1 1 1
645 2 2 4 no zeros
646 3 6 81 varchar
647 4 87 81 varchar
648 5 168 3 1 1 no zeros
649 6 171 3 1 2 no zeros
650
651 Explanations for the types of information myisamchk produces are given
652 here. “Keyfile” refers to the index file. “Record” and “row” are
653 synonymous, as are “field” and “column.”
654
655 The initial part of the table description contains these values:
656
657 · MyISAM file
658
659 Name of the MyISAM (index) file.
660
661 · Record format
662
663 The format used to store table rows. The preceding examples use
664 Fixed length. Other possible values are Compressed and Packed.
665 (Packed corresponds to what SHOW TABLE STATUS reports as Dynamic.)
666
667 · Chararacter set
668
669 The table default character set.
670
671 · File-version
672
673 Version of MyISAM format. Always 1.
674
675 · Creation time
676
677 When the data file was created.
678
679 · Recover time
680
681 When the index/data file was last reconstructed.
682
683 · Status
684
685 Table status flags. Possible values are crashed, open, changed,
686 analyzed, optimized keys, and sorted index pages.
687
688 · Auto increment key, Last value
689
690 The key number associated the table's AUTO_INCREMENT column, and
691 the most recently generated value for this column. These fields do
692 not appear if there is no such column.
693
694 · Data records
695
696 The number of rows in the table.
697
698 · Deleted blocks
699
700 How many deleted blocks still have reserved space. You can optimize
701 your table to minimize this space. See Section 7.6.4, “MyISAM Table
702 Optimization”.
703
704 · Datafile parts
705
706 For dynamic-row format, this indicates how many data blocks there
707 are. For an optimized table without fragmented rows, this is the
708 same as Data records.
709
710 · Deleted data
711
712 How many bytes of unreclaimed deleted data there are. You can
713 optimize your table to minimize this space. See Section 7.6.4,
714 “MyISAM Table Optimization”.
715
716 · Datafile pointer
717
718 The size of the data file pointer, in bytes. It is usually 2, 3, 4,
719 or 5 bytes. Most tables manage with 2 bytes, but this cannot be
720 controlled from MySQL yet. For fixed tables, this is a row address.
721 For dynamic tables, this is a byte address.
722
723 · Keyfile pointer
724
725 The size of the index file pointer, in bytes. It is usually 1, 2,
726 or 3 bytes. Most tables manage with 2 bytes, but this is calculated
727 automatically by MySQL. It is always a block address.
728
729 · Max datafile length
730
731 How long the table data file can become, in bytes.
732
733 · Max keyfile length
734
735 How long the table index file can become, in bytes.
736
737 · Recordlength
738
739 How much space each row takes, in bytes.
740
741 The table description part of the output includes a list of all keys in
742 the table. For each key, myisamchk displays some low-level information:
743
744 · Key
745
746 This key's number. This value is shown only for the first column of
747 the key. If this value is missing, the line corresponds to the
748 second or later column of a multiple-column key. For the table
749 shown in the example, there are two table description lines for the
750 second index. This indicates that it is a multiple-part index with
751 two parts.
752
753 · Start
754
755 Where in the row this portion of the index starts.
756
757 · Len
758
759 How long this portion of the index is. For packed numbers, this
760 should always be the full length of the column. For strings, it may
761 be shorter than the full length of the indexed column, because you
762 can index a prefix of a string column. The total length of a
763 multiple-part key is the sum of the Len values for all key parts.
764
765 · Index
766
767 Whether a key value can exist multiple times in the index. Possible
768 values are unique or multip. (multiple).
769
770 · Type
771
772 What data type this portion of the index has. This is a MyISAM data
773 type with the possible values packed, stripped, or empty.
774
775 · Root
776
777 Address of the root index block.
778
779 · Blocksize
780
781 The size of each index block. By default this is 1024, but the
782 value may be changed at compile time when MySQL is built from
783 source.
784
785 · Rec/key
786
787 This is a statistical value used by the optimizer. It tells how
788 many rows there are per value for this index. A unique index always
789 has a value of 1. This may be updated after a table is loaded (or
790 greatly changed) with myisamchk -a. If this is not updated at all,
791 a default value of 30 is given.
792
793 The last part of the output provides information about each column:
794
795 · Field
796
797 The column number.
798
799 · Start
800
801 The byte position of the column within table rows.
802
803 · Length
804
805 The length of the column in bytes.
806
807 · Nullpos, Nullbit
808
809 For columns that can be NULL, MyISAM stores NULL values as a flag
810 in a byte. Depending on how many nullable columns there are, there
811 can be one or more bytes used for this purpose. The Nullpos and
812 Nullbit values, if nonempty, indicate which byte and bit contains
813 that flag indicating whether the column is NULL.
814
815 The position and number of bytes used to store NULL flags is shown
816 in the line for field 1. This is why there are six Field lines for
817 the person table even though it has only five columns.
818
819 · Type
820
821 The data type. The value may contain any of the following
822 descriptors:
823
824 · constant
825
826 All rows have the same value.
827
828 · no endspace
829
830 Do not store endspace.
831
832 · no endspace, not_always
833
834 Do not store endspace and do not do endspace compression for
835 all values.
836
837 · no endspace, no empty
838
839 Do not store endspace. Do not store empty values.
840
841 · table-lookup
842
843 The column was converted to an ENUM.
844
845 · zerofill(N)
846
847 The most significant N bytes in the value are always 0 and are
848 not stored.
849
850 · no zeros
851
852 Do not store zeros.
853
854 · always zero
855
856 Zero values are stored using one bit.
857
858 · Huff tree
859
860 The number of the Huffman tree associated with the column.
861
862 · Bits
863
864 The number of bits used in the Huffman tree.
865
866 The Huff tree and Bits fields are displayed if the table has been
867 compressed with myisampack. See myisampack(1), for an example of this
868 information.
869
870 Example of myisamchk -eiv output:
871
872 Checking MyISAM file: person
873 Data records: 306688 Deleted blocks: 0
874 - check file-size
875 - check record delete-chain
876 No recordlinks
877 - check key delete-chain
878 block_size 1024:
879 - check index reference
880 - check data record references index: 1
881 Key: 1: Keyblocks used: 98% Packed: 0% Max levels: 3
882 - check data record references index: 2
883 Key: 2: Keyblocks used: 99% Packed: 97% Max levels: 3
884 - check data record references index: 3
885 Key: 3: Keyblocks used: 98% Packed: -14% Max levels: 3
886 Total: Keyblocks used: 98% Packed: 89%
887 - check records and index references*** LOTS OF ROW NUMBERS DELETED ***
888 Records: 306688 M.recordlength: 25 Packed: 83%
889 Recordspace used: 97% Empty space: 2% Blocks/Record: 1.00
890 Record blocks: 306688 Delete blocks: 0
891 Record data: 7934464 Deleted data: 0
892 Lost space: 256512 Linkdata: 1156096
893 User time 43.08, System time 1.68
894 Maximum resident set size 0, Integral resident set size 0
895 Non-physical pagefaults 0, Physical pagefaults 0, Swaps 0
896 Blocks in 0 out 7, Messages in 0 out 0, Signals 0
897 Voluntary context switches 0, Involuntary context switches 0
898 Maximum memory usage: 1046926 bytes (1023k)
899
900 myisamchk -eiv output includes the following information:
901
902 · Data records
903
904 The number of rows in the table.
905
906 · Deleted blocks
907
908 How many deleted blocks still have reserved space. You can optimize
909 your table to minimize this space. See Section 7.6.4, “MyISAM Table
910 Optimization”.
911
912 · Key
913
914 The key number.
915
916 · Keyblocks used
917
918 What percentage of the keyblocks are used. When a table has just
919 been reorganized with myisamchk, the values are very high (very
920 near theoretical maximum).
921
922 · Packed
923
924 MySQL tries to pack key values that have a common suffix. This can
925 only be used for indexes on CHAR and VARCHAR columns. For long
926 indexed strings that have similar leftmost parts, this can
927 significantly reduce the space used. In the preceding example, the
928 second key is 40 bytes long and a 97% reduction in space is
929 achieved.
930
931 · Max levels
932
933 How deep the B-tree for this key is. Large tables with long key
934 values get high values.
935
936 · Records
937
938 How many rows are in the table.
939
940 · M.recordlength
941
942 The average row length. This is the exact row length for tables
943 with fixed-length rows, because all rows have the same length.
944
945 · Packed
946
947 MySQL strips spaces from the end of strings. The Packed value
948 indicates the percentage of savings achieved by doing this.
949
950 · Recordspace used
951
952 What percentage of the data file is used.
953
954 · Empty space
955
956 What percentage of the data file is unused.
957
958 · Blocks/Record
959
960 Average number of blocks per row (that is, how many links a
961 fragmented row is composed of). This is always 1.0 for fixed-format
962 tables. This value should stay as close to 1.0 as possible. If it
963 gets too large, you can reorganize the table. See Section 7.6.4,
964 “MyISAM Table Optimization”.
965
966 · Recordblocks
967
968 How many blocks (links) are used. For fixed-format tables, this is
969 the same as the number of rows.
970
971 · Deleteblocks
972
973 How many blocks (links) are deleted.
974
975 · Recorddata
976
977 How many bytes in the data file are used.
978
979 · Deleted data
980
981 How many bytes in the data file are deleted (unused).
982
983 · Lost space
984
985 If a row is updated to a shorter length, some space is lost. This
986 is the sum of all such losses, in bytes.
987
988 · Linkdata
989
990 When the dynamic table format is used, row fragments are linked
991 with pointers (4 to 7 bytes each). Linkdata is the sum of the
992 amount of storage used by all such pointers.
993
995 Memory allocation is important when you run myisamchk. myisamchk uses
996 no more memory than its memory-related variables are set to. If you are
997 going to use myisamchk on very large tables, you should first decide
998 how much memory you want it to use. The default is to use only about
999 3MB to perform repairs. By using larger values, you can get myisamchk
1000 to operate faster. For example, if you have more than 512MB RAM
1001 available, you could use options such as these (in addition to any
1002 other options you might specify):
1003
1004 shell> myisamchk --myisam_sort_buffer_size=256M \
1005 --key_buffer_size=512M \
1006 --read_buffer_size=64M \
1007 --write_buffer_size=64M ...
1008
1009 Using --myisam_sort_buffer_size=16M is probably enough for most cases.
1010
1011 Be aware that myisamchk uses temporary files in TMPDIR. If TMPDIR
1012 points to a memory file system, out of memory errors can easily occur.
1013 If this happens, run myisamchk with the --tmpdir=dir_name option to
1014 specify a directory located on a file system that has more space.
1015
1016 When performing repair operations, myisamchk also needs a lot of disk
1017 space:
1018
1019 · Twice the size of the data file (the original file and a copy).
1020 This space is not needed if you do a repair with --quick; in this
1021 case, only the index file is re-created. This space must be
1022 available on the same file system as the original data file, as the
1023 copy is created in the same directory as the original.
1024
1025 · Space for the new index file that replaces the old one. The old
1026 index file is truncated at the start of the repair operation, so
1027 you usually ignore this space. This space must be available on the
1028 same file system as the original data file.
1029
1030 · When using --recover or --sort-recover (but not when using
1031 --safe-recover), you need space on disk for sorting. This space is
1032 allocated in the temporary directory (specified by TMPDIR or
1033 --tmpdir=dir_name). The following formula yields the amount of
1034 space required:
1035
1036 (largest_key + row_pointer_length) * number_of_rows * 2
1037
1038 You can check the length of the keys and the row_pointer_length
1039 with myisamchk -dv tbl_name (see the section called “OBTAINING
1040 TABLE INFORMATION WITH MYISAMCHK”). The row_pointer_length and
1041 number_of_rows values are the Datafile pointer and Data records
1042 values in the table description. To determine the largest_key
1043 value, check the Key lines in the table description. The Len column
1044 indicates the number of bytes for each key part. For a
1045 multiple-column index, the key size is the sum of the Len values
1046 for all key parts.
1047
1048 If you have a problem with disk space during repair, you can try
1049 --safe-recover instead of --recover.
1050
1052 Copyright © 1997, 2020, Oracle and/or its affiliates. All rights
1053 reserved.
1054
1055 This documentation is free software; you can redistribute it and/or
1056 modify it only under the terms of the GNU General Public License as
1057 published by the Free Software Foundation; version 2 of the License.
1058
1059 This documentation is distributed in the hope that it will be useful,
1060 but WITHOUT ANY WARRANTY; without even the implied warranty of
1061 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
1062 General Public License for more details.
1063
1064 You should have received a copy of the GNU General Public License along
1065 with the program; if not, write to the Free Software Foundation, Inc.,
1066 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA or see
1067 http://www.gnu.org/licenses/.
1068
1069
1071 For more information, please refer to the MySQL Reference Manual, which
1072 may already be installed locally and which is also available online at
1073 http://dev.mysql.com/doc/.
1074
1076 Oracle Corporation (http://dev.mysql.com/).
1077
1078
1079
1080MySQL 8.0 03/06/2020 MYISAMCHK(1)