我已经使用 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
...
最佳答案
如前所述here,WordPress 默认不能与 MySQL v8 一起工作.此外,wordpress
docker image readme 中的示例使用 MySQL v5.7。将 mysql 版本更改为 5.7 应该可以完成这项工作。
docker run --name mysql01 -e MYSQL_ROOT_PASSWORD=Password1234 -d mysql:5.7
如果您需要使用 mysql:latest
docker 镜像,使用 --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
关于mysql - WordPress docker 容器不以 mysql :latest image 开头,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/54505372/