问题概述:用Docker Compose搭建WordPress时出现Failed to initialize DD Storage Engine、Data Dictionary initialization failed.的错误
1、错误信息
截图:
my_wordpress-db-1 | 2022-09-25 06:42:54+00:00 [Note] [Entrypoint]: Entrypoint script for MySQL Server 8.0.27-1debian10 started.
my_wordpress-db-1 | 2022-09-25 06:42:54+00:00 [Note] [Entrypoint]: Switching to dedicated user 'mysql'
my_wordpress-db-1 | 2022-09-25 06:42:54+00:00 [Note] [Entrypoint]: Entrypoint script for MySQL Server 8.0.27-1debian10 started.
my_wordpress-db-1 | 2022-09-25T06:42:56.001990Z 0 [Warning] [MY-010918] [Server] 'default_authentication_plugin' is deprecated and will be removed in a future release. Please use authentication_policy instead.
my_wordpress-db-1 | 2022-09-25T06:42:56.002040Z 0 [System] [MY-010116] [Server] /usr/sbin/mysqld (mysqld 8.0.27) starting as process 1
my_wordpress-db-1 | 2022-09-25T06:42:56.044303Z 1 [System] [MY-013576] [InnoDB] InnoDB initialization has started.
my_wordpress-db-1 | 2022-09-25T06:42:56.389295Z 1 [ERROR] [MY-012960] [InnoDB] Cannot create log files because data files are corrupt or the database was not shut down cleanly after creating the data files.
my_wordpress-db-1 | 2022-09-25T06:42:56.389374Z 1 [ERROR] [MY-012930] [InnoDB] Plugin initialization aborted with error Generic error.
my_wordpress-wordpress-1 | AH00558: apache2: Could not reliably determine the server's fully qualified domain name, using 172.19.0.3. Set the 'ServerName' directive globally to suppress this message
my_wordpress-wordpress-1 | AH00558: apache2: Could not reliably determine the server's fully qualified domain name, using 172.19.0.3. Set the 'ServerName' directive globally to suppress this message
my_wordpress-wordpress-1 | [Sun Sep 25 06:42:56.717507 2022] [mpm_prefork:notice] [pid 1] AH00163: Apache/2.4.51 (Debian) PHP/7.4.27 configured -- resuming normal operations
my_wordpress-wordpress-1 | [Sun Sep 25 06:42:56.717599 2022] [core:notice] [pid 1] AH00094: Command line: 'apache2 -D FOREGROUND'
my_wordpress-db-1 | 2022-09-25T06:42:56.824291Z 1 [ERROR] [MY-010334] [Server] Failed to initialize DD Storage Engine
my_wordpress-db-1 | 2022-09-25T06:42:56.825425Z 0 [ERROR] [MY-010020] [Server] Data Dictionary initialization failed.
my_wordpress-db-1 | 2022-09-25T06:42:56.825627Z 0 [ERROR] [MY-010119] [Server] Aborting
my_wordpress-db-1 | 2022-09-25T06:42:56.826573Z 0 [System] [MY-010910] [Server] /usr/sbin/mysqld: Shutdown complete (mysqld 8.0.27) MySQL Community Server - GPL.
2、原因
错误发生原因暂时不清楚,可能是mysql镜像、容器有多个,导致冲突了,有见解的同学可以在评论区帮忙解惑一下,谢谢
3、解决办法
(1)把所有的关于mysql的镜像、容器全部删除
(2)用以下命令查找所有关于mysql的文件,然后全部删除
find / -name mysql
(3)不要使用官方的yml,用以下我修改过的yml
services:
db:
image: mysql:latest
command:
--default-authentication-plugin=mysql_native_password
volumes:
- /home/mysql/data:/var/lib/mysql
restart: always
environment:
- MYSQL_ROOT_PASSWORD=somewordpress
- MYSQL_DATABASE=wordpress
- MYSQL_USER=wordpress
- MYSQL_PASSWORD=wordpress
expose:
- 3306
- 33060
wordpress:
image: wordpress:latest
volumes:
- wp_data:/var/www/html
ports:
- 80:80
restart: always
environment:
- WORDPRESS_DB_HOST=db
- WORDPRESS_DB_USER=wordpress
- WORDPRESS_DB_PASSWORD=wordpress
- WORDPRESS_DB_NAME=wordpress
volumes:
wp_data:
(4)重新用docker compose up命令启动即可