Copyright (C) 2000-2012 |
GNU Info (mysql.info)Crash recoveryUsing `myisamchk' for Crash Recovery .................................... If you run `mysqld' with `--skip-locking' (which is the default on some systems, like Linux), you can't reliably use `myisamchk' to check a table when `mysqld' is using the same table. If you can be sure that no one is accessing the tables through `mysqld' while you run `myisamchk', you only have to do `mysqladmin flush-tables' before you start checking the tables. If you can't guarantee the above, then you must take down `mysqld' while you check the tables. If you run `myisamchk' while `mysqld' is updating the tables, you may get a warning that a table is corrupt even if it isn't. If you are not using `--skip-locking', you can use `myisamchk' to check tables at any time. While you do this, all clients that try to update the table will wait until `myisamchk' is ready before continuing. If you use `myisamchk' to repair or optimize tables, you *MUST* always ensure that the `mysqld' server is not using the table (this also applies if you are using `--skip-locking'). If you don't take down `mysqld' you should at least do a `mysqladmin flush-tables' before you run `myisamchk'. This chapter describes how to check for and deal with data corruption in MySQL databases. If your tables get corrupted a lot you should try to find the reason for this! Note: Crashing. The `MyISAM' table section contains reason for why a table could be corrupted. Note: MyISAM table problems. When performing crash recovery, it is important to understand that each table `tbl_name' in a database corresponds to three files in the database directory: *File* *Purpose* `tbl_name.frm' Table definition (form) file `tbl_name.MYD' Data file `tbl_name.MYI' Index file Each of these three file types is subject to corruption in various ways, but problems occur most often in data files and index files. `myisamchk' works by creating a copy of the `.MYD' (data) file row by row. It ends the repair stage by removing the old `.MYD' file and renaming the new file to the original file name. If you use `--quick', `myisamchk' does not create a temporary `.MYD' file, but instead assumes that the `.MYD' file is correct and only generates a new index file without touching the `.MYD' file. This is safe, because `myisamchk' automatically detects if the `.MYD' file is corrupt and aborts the repair in this case. You can also give two `--quick' options to `myisamchk'. In this case, `myisamchk' does not abort on some errors (like duplicate key) but instead tries to resolve them by modifying the `.MYD' file. Normally the use of two `--quick' options is useful only if you have too little free disk space to perform a normal repair. In this case you should at least make a backup before running `myisamchk'. automatically generated by info2www version 1.2.2.9 |