使用phpmyadmin和docker-compose的身份验证错误

时间:2019-05-08 09:49:31

标签: mysql docker phpmyadmin docker-compose

我正在尝试为mysql和phpmyadmin用户使用docker-compose,但是尝试登录phpmyadmin时出现身份验证错误。我正在寻求有关此主题以及如何构建正确的docker_compose.yml文件的帮助。

我尝试对yml文件进行严格的配置,但没有成功。

这是yml即时通讯使用:

version: '3'

services:

  db:
    image: mysql
    command: --default-authentication-plugin=mysql_native_password
    restart: always
    environment:
      MYSQL_DATABASE: mydb
      MYSQL_USER: root
      MYSQL_PASSWORD: admin
      MYSQL_ROOT_PASSWORD: admin
    volumes:
      - my-db:/var/lib/mysql

  phpmyadmin:
          image: phpmyadmin/phpmyadmin:latest
          links:
            - db
          ports:
            - 8080:80
          restart: always
          environment:
              PMA_USER: root
              PMA_PASSWORD: admin

volumes:
  my-db: {}

当我尝试登录phpmyadmin时,出现以下错误:

  • mysqli_real_connect():服务器请求客户端未知的身份验证方法[caching_sha2_password]
  • mysqli_real_connect():(HY000 / 2054):服务器请求了客户端未知的身份验证方法

我试图将yml更改为:

version: '3'

services:

  db:
    image: mysql:57
    restart: always
    environment:

但是容器没有上升,它给出以下消息:

  • docker_db_1退出,代码为1

有人遇到相同的问题吗?

谢谢大家。

2 个答案:

答案 0 :(得分:1)

这很好:

version: '3'

services:

  db:
    image: mysql:5.7
    command: --default-authentication-plugin=mysql_native_password
    restart: always
    environment:
      MYSQL_DATABASE: mydb
      MYSQL_USER: root
      MYSQL_PASSWORD: admin
      MYSQL_ROOT_PASSWORD: admin
    volumes:
      - my-db:/var/lib/mysql

  phpmyadmin:
          image: phpmyadmin/phpmyadmin:latest
          links:
            - db
          ports:
            - 8080:80
          restart: always
          environment:
              PMA_USER: root
              PMA_PASSWORD: admin

volumes:
  my-db: {}

请记住在运行前删除卷(以防遇到问题)。

答案 1 :(得分:0)

我刚刚将此代码复制到docker-compose.yml

version: '3'

services:

  db:
    image: mysql
    command: --default-authentication-plugin=mysql_native_password
    restart: always
    environment:
      MYSQL_DATABASE: mydb
      MYSQL_USER: root
      MYSQL_PASSWORD: admin
      MYSQL_ROOT_PASSWORD: admin
    volumes:
      - my-db:/var/lib/mysql

  phpmyadmin:
          image: phpmyadmin/phpmyadmin:latest
          links:
            - db
          ports:
            - 8080:80
          restart: always
          environment:
              PMA_USER: root
              PMA_PASSWORD: admin

volumes:
  my-db: {}

并运行命令docker stack deploy -c docker-compose.yml mysqllab

这是结果

enter image description here