일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | 2 | 3 | 4 | 5 | 6 | 7 |
8 | 9 | 10 | 11 | 12 | 13 | 14 |
15 | 16 | 17 | 18 | 19 | 20 | 21 |
22 | 23 | 24 | 25 | 26 | 27 | 28 |
29 | 30 | 31 |
- 인증
- git
- Xcode
- FIDO2
- otpkey
- MFA
- MYSQL
- albumbook
- 앱리소스
- MSYS2
- Nodejs
- openssl
- fido
- SSH
- SSL
- SWIFT
- 앱스토어
- appres
- 애플
- kmip
- 2FA
- apple
- WebAuthn
- css
- Android
- 앨범북
- 안드로이드
- OSX
- OTP
- SwiftUI
- Today
- Total
인디노트
Rebuilding or Repairing Tables or Indexes 본문
2.11.3 Rebuilding or Repairing Tables or Indexes
This section describes how to rebuild or repair tables or indexes, which may be necessitated by:
Changes to how MySQL handles data types or character sets. For example, an error in a collation might have been corrected, necessitating a table rebuild to update the indexes for character columns that use the collation.
Required table repairs or upgrades reported by
CHECK TABLE
, mysqlcheck, or mysql_upgrade.
Methods for rebuilding a table include:
If you are rebuilding tables because a different version of MySQL will not handle them after a binary (in-place) upgrade or downgrade, you must use the dump-and-reload method. Dump the tables before upgrading or downgrading using your original version of MySQL. Then reload the tables after upgrading or downgrading.
If you use the dump-and-reload method of rebuilding tables only for the purpose of rebuilding indexes, you can perform the dump either before or after upgrading or downgrading. Reloading still must be done afterward.
If you need to rebuild an InnoDB
table because a CHECK TABLE
operation indicates that a table upgrade is required, usemysqldump to create a dump file and mysql to reload the file. If the CHECK TABLE
operation indicates that there is a corruption or causes InnoDB
to fail, refer to Section 14.21.2, “Forcing InnoDB Recovery” for information about using theinnodb_force_recovery
option to restart InnoDB
. To understand the type of problem that CHECK TABLE
may be encountering, refer to the InnoDB
notes in Section 13.7.2.2, “CHECK TABLE Syntax”.
To rebuild a table by dumping and reloading it, use mysqldump to create a dump file and mysql to reload the file:
mysqldump db_name t1 > dump.sql
mysql db_name < dump.sql
To rebuild all the tables in a single database, specify the database name without any following table name:
mysqldump db_name > dump.sql
mysql db_name < dump.sql
To rebuild all tables in all databases, use the --all-databases
option:
mysqldump --all-databases > dump.sql
mysql < dump.sql
To rebuild a table with ALTER TABLE
, use a “null” alteration; that is, an ALTER TABLE
statement that “changes” the table to use the storage engine that it already has. For example, if t1
is an InnoDB
table, use this statement:
ALTER TABLE t1 ENGINE = InnoDB;
If you are not sure which storage engine to specify in the ALTER TABLE
statement, use SHOW CREATE TABLE
to display the table definition.
The REPAIR TABLE
method is only applicable to MyISAM
, ARCHIVE
, and CSV
tables.
You can use REPAIR TABLE
if the table checking operation indicates that there is a corruption or that an upgrade is required. For example, to repair a MyISAM
table, use this statement:
REPAIR TABLE t1;
mysqlcheck --repair provides command-line access to the REPAIR TABLE
statement. This can be a more convenient means of repairing tables because you can use the --databases
or --all-databases
option to repair all tables in specific databases or all databases, respectively:
mysqlcheck --repair --databases db_name ...
mysqlcheck --repair --all-databases
'개발 플랫폼 및 언어' 카테고리의 다른 글
Windows 버전별 기본 설치되는 .NET Framework 버전 (0) | 2018.02.02 |
---|---|
MySQL DB 의 ibdata1 파일이 날라갔을 때 복구 (0) | 2018.01.31 |
Linux yum 패키지 클린하고 새로 설치하기 (0) | 2018.01.31 |
리눅스 백그라운드로 실행하기 - 터미널 닫아도 유지되는 (0) | 2017.11.15 |
How to install GIT 2.10.2 on CentOS (0) | 2017.11.08 |