WordPress Docker容器不以mysql:latest开头

时间:2019-02-03 17:08:49

标签: mysql wordpress docker

我已经用mariadb容器设置了wordpress,没有任何问题。

现在,我正在尝试使用mysql测试wordpress。

使用的命令:

$ docker run --name mysql01 -e MYSQL_ROOT_PASSWORD=Password1234 -d mysql
$ docker run --name wordpress01 --link mysql01 -p 8080:80 -e WORDPRESS_DB_HOST=mysql01:3306 -e WORDPRESS_DB_USER=root -e WORDPRESS_DB_PASSWORD=Password1234 -e WORDPRESS_DB_NAME=wordpress -e WORDPRESS_TABLE_PREFIX=wp_ -d wordpress

容器状态:

$ docker ps 
CONTAINER ID        IMAGE               COMMAND                  CREATED             STATUS              PORTS                 NAMES
e71299679e73        mysql               "docker-entrypoint..."   2 minutes ago       Up 2 minutes        3306/tcp, 33060/tcp   mysql01

$ docker ps -a 
CONTAINER ID        IMAGE               COMMAND                  CREATED             STATUS                     PORTS                 NAMES
c0a7dd46fb33        wordpress           "docker-entrypoint..."   5 minutes ago       Exited (1) 4 minutes ago                         wordpress01
e71299679e73        mysql               "docker-entrypoint..."   7 minutes ago       Up 7 minutes               3306/tcp, 33060/tcp   mysql01

错误日志:

$ docker logs wordpress01 
WordPress not found in /var/www/html - copying now...
Complete! WordPress has been successfully copied to /var/www/html

Warning: mysqli::__construct(): (HY000/2002): Connection refused in Standard input code on line 22

MySQL Connection Error: (2002) Connection refused

Warning: mysqli::__construct(): (HY000/2002): Connection refused in Standard input code on line 22

MySQL Connection Error: (2002) Connection refused

Warning: mysqli::__construct(): (HY000/2002): Connection refused in Standard input code on line 22

MySQL Connection Error: (2002) Connection refused

Warning: mysqli::__construct(): The server requested authentication method unknown to the client [caching_sha2_password] in Standard input code on line 22

Warning: mysqli::__construct(): (HY000/2054): The server requested authentication method unknown to the client in Standard input code on line 22

MySQL Connection Error: (2054) The server requested authentication method unknown to the client
...

1 个答案:

答案 0 :(得分:1)

默认情况下,WordPress无法在MySQL v8上运行,如here所述。此外,wordpress泊坞镜映像readme中的示例使用MySQL v5.7。将mysql版本更改为5.7应该可以完成这项工作。

docker run --name mysql01 -e MYSQL_ROOT_PASSWORD=Password1234 -d mysql:5.7

如果您需要使用mysql:latest码头工人镜像,则以--default-authentication-plugin=mysql_native_password参数启动mysql也应按here所述进行工作。

docker run --name mysql01 -e MYSQL_ROOT_PASSWORD=Password1234 -d mysql --default-authentication-plugin=mysql_native_password
相关问题