tail -f /var/log/mysql/error.log したときに

This could be because you hit a bug. It is also possible that this binary
or one of the libraries it was linked against is corrupt, improperly built,
or misconfigured. This error can also be caused by malfunctioning hardware.
We will try our best to scrape up some info that will hopefully help
diagnose the problem, but since we have already crashed,
something is definitely wrong and this may fail.


1. 強制リカバリーモードで立ち上がるように変更

sudo nano /etc/mysql/my.cnf

innodb_force_recovery = 3


2. MySQLを再起動

sudo service mysql restart
  • 起動しない場合は,ps aux | grep mysql して,当該PIDをkillする
  • その上で,sudo service mysql start する

3. データベースダンプ

mysqldump --events -u root -p -x --all-database > all-database.sql
mysqldump --events -u root -p -x --allow-keywords mysql > allow-keywords.sql

4. datadirを一時退避

sudo mv /var/lib/mysql ~/mysql_datadir_backup

5. datadir 再生成

sudo mkdir /var/lib/mysql
sudo chown mysql:mysql /var/lib/mysql

6. 強制リカバリーモードを解除

sudo nano /etc/mysql/my.cnf して

innodb_force_recovery = 3


7. datadir登録

mysql_install_db --datadir=/var/lib/mysql --user=mysql

8. プロセス起動

sudo service mysql start

9. データベースインポート

mysql -u root < all-database.sql
mysql -u root mysql < allow-keywords.sql

10. プロセス再起動

sudo service mysql restart

11. 退避したdatadirを削除


sudo rm -rf ~/mysql_datadir_backup