MySQL¶
ユーザ¶
作成¶
GRANT USAGE, SELECT,INSERT,UPDATE,DELETE,CREATE,DROP ON test.* TO test@localhost IDENTIFIED BY ‘secret’;
障害対応¶
テーブル壊れた(ディスク溢れ)¶
結論:myisamchkを使う
ある日,/var/dbが溢れた./usr/local/dbにmvしたけど,mysqlにconnectすると,
Didn't find any fields in table 'tag_record'
といわれた。
-rw-rw---- 1 mysql mysql 125428736 11 9 17:37 tag_record.MYI
だ居るが存在するが、テーブルが見えていない。 まずはテーブルが壊れているかチェック. db/mysql/tableの中で,
# myisamchk tag_record
Checking MyISAM file: tag_record
Data records: 2062312 Deleted blocks: 0
myisamchk: warning: Table is marked as crashed
- check file-size
myisamchk: error: Size of datafile is: 137068544 Should be: 137068564
- check record delete-chain
- check key delete-chain
- check index reference
- check data record references index: 1
- check data record references index: 2
- check data record references index: 3
- check data record references index: 4
- check data record references index: 5
- check record links
myisamchk: error: got error: 127 when reading datafile at record: 2062278
MyISAM-table 'tag_record' is corrupted
Fix it using switch "-r" or "-o"
やっぱり,エラーがある.
# myisamchk --recover tag_record
- recovering (with sort) MyISAM-table 'tag_record'
Data records: 2062312
- Fixing index 1
Found link that points at 137068544 (outside data file) at 137066488
- Fixing index 2
- Fixing index 3
- Fixing index 4
- Fixing index 5
Data records: 2062311
これでOK