用Docker Compose搭建WordPress时出现The designated data directory /var/lib/mysql/ is unusable的错误
用Docker Compose搭建WordPress时出现The designated data directory /var/lib/mysql/ is unusable的错误
·
1、错误信息
截图:
Attaching to my_wordpress-db-1, my_wordpress-wordpress-1
my_wordpress-db-1 | 2022-09-25 07:57:05+00:00 [Note] [Entrypoint]: Entrypoint script for MySQL Server 8.0.27-1debian10 started.
my_wordpress-db-1 | 2022-09-25 07:57:06+00:00 [Note] [Entrypoint]: Switching to dedicated user 'mysql'
my_wordpress-db-1 | 2022-09-25 07:57:06+00:00 [Note] [Entrypoint]: Entrypoint script for MySQL Server 8.0.27-1debian10 started.
my_wordpress-wordpress-1 | AH00558: apache2: Could not reliably determine the server's fully qualified domain name, using 172.19.0.2. 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.2. Set the 'ServerName' directive globally to suppress this message
my_wordpress-db-1 | 2022-09-25 07:57:06+00:00 [Note] [Entrypoint]: Initializing database files
my_wordpress-db-1 | 2022-09-25T07:57:06.492880Z 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-25T07:57:06.492911Z 0 [System] [MY-013169] [Server] /usr/sbin/mysqld (mysqld 8.0.27) initializing of server in progress as process 40
my_wordpress-db-1 | 2022-09-25T07:57:06.499967Z 0 [ERROR] [MY-010457] [Server] --initialize specified but the data directory has files in it. Aborting.
my_wordpress-db-1 | 2022-09-25T07:57:06.499989Z 0 [ERROR] [MY-013236] [Server] The designated data directory /var/lib/mysql/ is unusable. You can remove all files that the server added to it.
my_wordpress-db-1 | 2022-09-25T07:57:06.500122Z 0 [ERROR] [MY-010119] [Server] Aborting
my_wordpress-db-1 | 2022-09-25T07:57:06.500419Z 0 [System] [MY-010910] [Server] /usr/sbin/mysqld: Shutdown complete (mysqld 8.0.27) MySQL Community Server - GPL.
my_wordpress-wordpress-1 | [Sun Sep 25 07:57:06.506845 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 07:57:06.506951 2022] [core:notice] [pid 1] AH00094: Command line: 'apache2 -D FOREGROUND'
2、原因
错误发生原因暂时不清楚,有见解的同学可以在评论区帮忙解惑一下,谢谢
3、解决办法
原本搭建WordPress用的是官方的yml,如下:
services:
db:
image: mysql:latest
command: '--default-authentication-plugin=mysql_native_password'
volumes:
- db_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:
db_data:
wp_data:
后来我把yml改成如下,就不报错了(这是我的解决办法,可能不是每个人都适用,把db里的volumes里的db_data删掉,然后把路径补全,把最下面的volumes里的db_data删掉)
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:
更多推荐
已为社区贡献19条内容
所有评论(0)