1

我正在尝试使用来自 docker hub 的官方adminer和图像连接到我的 mysql 数据库。mysql

这是我的docker-compose.yml文件配置:

version: '3'
services:
  mysql:
    image: mysql
    restart: always
    volumes: 
      - mysql:/var/lib/mysql
    environment: 
      - MYSQL_ALLOW_EMPTY_PASSWORD= 1
      - MYSQL_DATABASE= db
    ports: 
      - 3306:3306
      - 33060:33060
  adminer:
    image: adminer
    restart: always
    ports:
      - 8080:8080
    depends_on: 
      - mysql
volumes:
  mysql:

每当我想使用Adminer登录MySQL时,都会遇到以下问题:

SQLSTATE[HY000] [2054] 服务器请求客户端未知的身份验证方法

SQLSTATE[HY000] [2002] 没有这样的文件或目录

这是我用来尝试从管理员界面连接到 MySQL 的输入:

#first try
System: MySQL
Server: localhost
Username: root
Database: db

#second try
System: MySQL
Server: mysql #container-name
Username: root
Database: db
4

1 回答 1

3

您必须在撰写文件中添加默认身份验证插件

command: --default-authentication-plugin=mysql_native_password

这是完整的 docker-compose.yml

services:
  mysql:
    image: mysql
    restart: always
    command: --default-authentication-plugin=mysql_native_password
    volumes: 
      - mysql:/var/lib/mysql
    environment: 
      - MYSQL_ALLOW_EMPTY_PASSWORD= 1
      - MYSQL_DATABASE= db
    ports: 
      - 3306:3306
      - 33060:33060
  adminer:
    image: adminer
    restart: always
    ports:
      - 8080:8080
    depends_on: 
      - mysql
volumes:
  mysql:

在管理员中

System: MySQL <DB System to connect>
Server: mysql <should match the starting tag before image tag > (in your case mysql but you can change it to any name )
Username: root <username>
Password: <password>
Database: db <database name>
于 2019-10-16T03:33:23.980 回答