Dockerでmysqlのイメージのバージョンを8.0から5.7.44に下げたことによるエラー
Dockerでmysqlのイメージのバージョンを8.0から5.7.44に下げたらmysqlのコンテナが立ち上がらなくなってしまった。 Docker Desktopを確認すると以下のような状態であった。
Docker Desktopのmysqlコンテナのログを確認すると以下のようなエラーが出ていた。
2024-06-25 14:55:41 2024-06-25T05:55:41.376353Z 0 [ERROR] [FATAL] InnoDB: Table flags are 0 in the data dictionary but the flags in file ./ibdata1 are 0x4800! 2024-06-25 14:55:41 2024-06-25 14:55:41 0x7ffffbe5e880 InnoDB: Assertion failure in thread 140737419536512 in file ut0ut.cc line 921 2024-06-25 14:55:41 InnoDB: We intentionally generate a memory trap. 2024-06-25 14:55:41 InnoDB: Submit a detailed bug report to http://bugs.mysql.com. 2024-06-25 14:55:41 InnoDB: If you get repeated assertion failures or crashes, even 2024-06-25 14:55:41 InnoDB: immediately after the mysqld startup, there may be 2024-06-25 14:55:41 InnoDB: corruption in the InnoDB tablespace. Please refer to 2024-06-25 14:55:41 InnoDB: http://dev.mysql.com/doc/refman/5.7/en/forcing-innodb-recovery.html 2024-06-25 14:55:41 InnoDB: about forcing recovery. 2024-06-25 14:55:41 05:55:41 UTC - mysqld got signal 6 ; 2024-06-25 14:55:41 This could be because you hit a bug. It is also possible that this binary 2024-06-25 14:55:41 or one of the libraries it was linked against is corrupt, improperly built, 2024-06-25 14:55:41 or misconfigured. This error can also be caused by malfunctioning hardware. 2024-06-25 14:55:41 Attempting to collect some information that could help diagnose the problem. 2024-06-25 14:55:41 As this is a crash and something is definitely wrong, the information 2024-06-25 14:55:41 collection process might fail.
docker compose upを実行して、localhostにアクセスすると以下のような画面になった。
dockerのイメージ、コンテナ、volumeを削除すると解決できた。 具体的なコマンドと操作手順は、以下のようになる。
①コンテナの削除
docker ps -aでコンテナの一覧を表示する
上記で出てきたコンテナを以下のコマンドで全て削除する
docker rm コンテナID
②イメージの削除
docker imagesでイメージの一覧を表示する
上記で出てきたイメージを以下のコマンドで全て削除する
docker rmi イメージ名
③volumeの削除
docker volume lsでvolumeの一覧を表示する
上記で出てきたvolumeを以下のコマンドで全て削除する
docker volume rm VOLUMEのID
④buildのやり直し
docker-compose build --no-cache
⑤起動する
docker-compose up -d
mysqlのイメージのバージョンを8.0から5.7.44に下げたことで、InnoDBが8.0から4.7への移行をサポートしていなく今回のエラーになった可能性があります。

