mysql 모든 디비 복구 및 패키지버전 업그레이드시 시스템 테이블 업그레이드 방법

디비오류로그 (tail -n200 /usr/local/mysql/data/localhost.err) 보면 깨진 디비의 테이블확인 가능
"Table '[TABLE_NAME]' is marked as crashed and should be repaired"

/usr/local/mysql/bin/mysqlcheck -Aao --auto-repair -u root -p

mysqld restart 시 localhost.err 에 
110423 19:14:25 [ERROR] Column count of mysql.db is wrong. Expected 22, found 15. The table is probably corrupted
110423 19:14:25 [ERROR] mysql.user has no `Event_priv` column at position 29
110423 19:14:25 [ERROR] Event Scheduler: An error occurred when initializing system tables. Disabling the Event Scheduler. 
라는 메시지가 있다면 mysql  업드레이시 시스템 테이블 업그레이드가  안된것.
기존에 5.0 버전에서 5.1로 업그레이시 발생 될 수 있음.
해결 방법은  
/usr/local/mysql/bin/mysql_upgrade  -u root --password
실행후 mysqld restart 하면 업그레이드된 user와 db 시스템 테이블이 업그레이드 된다.

@http://superkkt.com/568 
superkkt 블로그 에서는 업그레이드시 아래의 오류가 나오는 경우가 있다고 하는데 데비안에서 사용시인것 같다.

참고로 MySQL 재시작 과정에서 아래와 같은 에러 로그가 나온다면 debian-sys-maint 사용자를 등록해줘야한다.

Aug  2 13:45:53 wiz-1 /etc/mysql/debian-start[3827]: /usr/bin/mysqlcheck: Got error: 1045: Access denied for user 'debian-sys-maint'@'localhost' (using password: YES) when trying to connect
Aug  2 13:45:53 wiz-1 /etc/mysql/debian-start[3827]: FATAL ERROR: Upgrade failed

먼저 /etc/mysql/debian.cnf 파일에서 mysql-upgrade 영역에 있는 debian-sys-maint 사용자의 패스워드를 복사한다. 이 예제에서는 TEXSvTrT215CxmAx 이다. 그 다음에 MySQL에 root로 접속해서 아래와 같이 사용자를 등록해준다.

GRANT ALL PRIVILEGES ON *.* TO 'debian-sys-maint'@'localhost' IDENTIFIED BY 'TEXSvTrT215CxmAx' WITH GRANT OPTION;
 
 



Reference
http://superkkt.com/568