使用Wordpress和MySQL Docker映像时出现未知的身份验证方法错误 [英] Unknown authentication method error while using wordpress and mysql docker images

查看:55
本文介绍了使用Wordpress和MySQL Docker映像时出现未知的身份验证方法错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试通过docker在mysql上安装wordpress,但是数据库容器和wordpress容器之间出现通讯错误.

I am trying to install wordpress with mysql via docker but I have communication errors between the container of the DB and the wordpress container.

这是我的docker-compose.yml文件

here is my docker-compose.yml file

version: '3'

services:
   db:
     image: mysql:latest
     volumes:
       - db_data:/var/lib/mysql
     restart: always
     environment:
       MYSQL_ROOT_PASSWORD: wordpress
       MYSQL_DATABASE: wordpress
       MYSQL_USER: wordpress
       MYSQL_PASSWORD: wordpress

   wordpress:
     depends_on:
       - db
     links:
       - db
     image: wordpress:latest
     ports:
       - "8000:80"
     restart: always
     environment:
       WORDPRESS_DB_HOST: db:3306
       WORDPRESS_DB_USER: wordpress
       WORDPRESS_DB_PASSWORD: wordpress
volumes: 
    db_data:

如果我执行"docker-compose up -d"命令并打开wordpress容器的日志,则会出现此错误:

If I execute the "docker-compose up -d" command and that I open the logs of the wordpress container I have this error:

...
wordpress_1  | Warning: mysqli::__construct(): The server requested authentication method unknown to the client [caching_sha2_password] in Standard input code on line 22
wordpress_1  |
wordpress_1  | Warning: mysqli::__construct(): (HY000/2054): The server requested authentication method unknown to the client in Standard input code on line 22
wordpress_1  |
wordpress_1  | MySQL Connection Error: (2054) The server requested authentication method unknown to the client
...

我在db部分中添加了命令:'--default-authentication plugin = mysql_native_password',我将mysql版本更改为5.7,但这并没有帮助我解决问题.我还访问了这些讨论:

I added command: '--default-authentication plugin=mysql_native_password' in the db section and i changed the mysql version to 5.7 but it did not help me solve the problem. I also visited these discussions :

docker上的Wordpress-不运行

https://serverfault.com/questions/880773/unable-to-access-wordpress-site-created-as-a-docker-stack/880777#880777

https://github.com/docker-library/wordpress/issues/313

预先感谢您的建议.

推荐答案

似乎WordPress/PHP 尚不支持 MySQL v8.甚至 wordpress docker映像自述文件建议使用 MySQL v5.7.将mysql版本更改为v5.7后,您可能会注意到MySQL容器崩溃,并显示类似以下的错误:

It seems that WordPress/PHP doesn't support MySQL v8 yet. Even wordpress docker image readme suggests to use MySQL v5.7. After changing mysql version to v5.7, you might notice that MySQL container crashes with an error similar to below:

...
db_1         | 2019-01-28T18:45:24.611045Z 0 [ERROR] [FATAL] InnoDB: Table flags are 0 in the data dictionary but the flags in file ./ibdata1 are 0x4800!
db_1         | 2019-01-28 18:45:24 0x7f00e013a740  InnoDB: Assertion failure in thread 139641736111936 in file ut0ut.cc line 942
db_1         | InnoDB: We intentionally generate a memory trap.
...

要解决此问题,最简单的方法是使用 docker-compose down -v 删除MySQL docker卷.之后, docker-compose up -d 应该可以工作.

To fix this, easiest way is to delete the MySQL docker volume using docker-compose down -v. After that, docker-compose up -d should work.

如果仍然无法解决问题,请使用> https://hub中的docker-compose示例.docker.com/_/wordpress/.在将来添加时将其添加到这里.

If that still doesn't work, use the docker-compose example from https://hub.docker.com/_/wordpress/. Adding it here in case it gets pulled down in future.

version: '3.1'

services:

  wordpress:
    image: wordpress
    restart: always
    ports:
      - 8080:80
    environment:
      WORDPRESS_DB_HOST: db
      WORDPRESS_DB_USER: exampleuser
      WORDPRESS_DB_PASSWORD: examplepass
      WORDPRESS_DB_NAME: exampledb

  db:
    image: mysql:5.7
    restart: always
    environment:
      MYSQL_DATABASE: exampledb
      MYSQL_USER: exampleuser
      MYSQL_PASSWORD: examplepass
      MYSQL_RANDOM_ROOT_PASSWORD: '1'

这篇关于使用Wordpress和MySQL Docker映像时出现未知的身份验证方法错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆