使用docker-compose运行MySql;登录错误:“服务器请求的客户端未知的身份验证方法”

时间:2018-05-23 06:38:56

标签: mysql docker docker-compose

我需要运行MySql docker容器。按照MySql官方Docker存储库(https://hub.docker.com/_/mysql/)上的说明,我执行了以下步骤:

步骤1.我按如下方式编写了stack.yml文件,然后运行: docker-compose -f stack.yml up

version: '3.1'

services:

  db:
    image: mysql
    restart: always
    environment:
      MYSQL_ROOT_PASSWORD: example

  adminer:
    image: adminer
    restart: always
    ports:
      - 8080:8080

步骤2.浏览到http://localhost:8080/

显示登录表单。它说:

系统:MySql

服务器:db

然后我输入 root 作为用户名,输入示例作为密码,并将数据库文本框保留为空,然后单击登录。 它显示错误: “ SQLSTATE [HY000] [2054]服务器请求客户端未知的身份验证方法

如何解决这个问题的任何提示/线索将非常感激。提前谢谢!

======

以下是来自终端:

docker-compose -f stack.yml up

Starting hibernate_db_1      ... done
Starting hibernate_adminer_1 ... done
Attaching to hibernate_db_1, hibernate_adminer_1
db_1       | 2018-05-23T07:34:08.186378Z 0 [Warning] [MY-011070] [Server] 'Disabling symbolic links using --skip-symbolic-links (or equivalent) is the default. Consider not using this option as it' is deprecated and will be removed in a future release.
db_1       | 2018-05-23T07:34:08.186678Z 0 [System] [MY-010116] [Server] /usr/sbin/mysqld (mysqld 8.0.11) starting as process 1
db_1       | mbind: Operation not permitted
db_1       | mbind: Operation not permitted
adminer_1  | PHP 7.2.5 Development Server started at Wed May 23 07:34:08 2018
db_1       | 2018-05-23T07:34:09.011741Z 0 [System] [MY-010229] [Server] Starting crash recovery...
db_1       | 2018-05-23T07:34:09.012443Z 0 [System] [MY-010232] [Server] Crash recovery finished.
db_1       | 2018-05-23T07:34:09.214122Z 0 [Warning] [MY-010068] [Server] CA certificate ca.pem is self signed.
db_1       | 2018-05-23T07:34:09.226905Z 0 [Warning] [MY-011810] [Server] Insecure configuration for --pid-file: Location '/var/run/mysqld' in the path is accessible to all OS users. Consider choosing a different directory.
db_1       | 2018-05-23T07:34:09.255716Z 0 [Warning] [MY-010315] [Server] 'user' entry 'mysql.infoschema@localhost' ignored in --skip-name-resolve mode.
db_1       | 2018-05-23T07:34:09.256491Z 0 [Warning] [MY-010315] [Server] 'user' entry 'mysql.session@localhost' ignored in --skip-name-resolve mode.
db_1       | 2018-05-23T07:34:09.256797Z 0 [Warning] [MY-010315] [Server] 'user' entry 'mysql.sys@localhost' ignored in --skip-name-resolve mode.
db_1       | 2018-05-23T07:34:09.257188Z 0 [Warning] [MY-010315] [Server] 'user' entry 'root@localhost' ignored in --skip-name-resolve mode.
db_1       | 2018-05-23T07:34:09.257654Z 0 [Warning] [MY-010323] [Server] 'db' entry 'performance_schema mysql.session@localhost' ignored in --skip-name-resolve mode.
db_1       | 2018-05-23T07:34:09.258015Z 0 [Warning] [MY-010323] [Server] 'db' entry 'sys mysql.sys@localhost' ignored in --skip-name-resolve mode.
db_1       | 2018-05-23T07:34:09.258420Z 0 [Warning] [MY-010311] [Server] 'proxies_priv' entry '@ root@localhost' ignored in --skip-name-resolve mode.
db_1       | 2018-05-23T07:34:09.273119Z 0 [Warning] [MY-010330] [Server] 'tables_priv' entry 'user mysql.session@localhost' ignored in --skip-name-resolve mode.
db_1       | 2018-05-23T07:34:09.273798Z 0 [Warning] [MY-010330] [Server] 'tables_priv' entry 'sys_config mysql.sys@localhost' ignored in --skip-name-resolve mode.
db_1       | 2018-05-23T07:34:09.299367Z 0 [System] [MY-010931] [Server] /usr/sbin/mysqld: ready for connections. Version: '8.0.11'  socket: '/var/run/mysqld/mysqld.sock'  port: 3306  MySQL Community Server - GPL.

当我浏览到http://localhost:8080时,终端会打印:

adminer_1  | [Wed May 23 07:34:28 2018] ::ffff:172.18.0.1:35388 [200]: /

点击登录后,终端打印:

adminer_1  | [Wed May 23 07:34:41 2018] ::ffff:172.18.0.1:35396 [302]: /
adminer_1  | [Wed May 23 07:34:41 2018] ::ffff:172.18.0.1:35398 [403]: /?server=db&username=root

2 个答案:

答案 0 :(得分:1)

adminer与mysql8兼容,使用了一些扩展,如主页上对adminer的要求一样。 https://www.adminer.org/

  

通过扩展程序与mysql 4.1,5.0,5.1,5.5,5.6,5.7,8.0进行混合:mysql,mysqli,pdo_mysql

所以你可以恢复到mysql-5.7

    version: '3.1'

    services:

      db:
        image: mysql:5.7
        restart: always
        environment:
          MYSQL_ROOT_PASSWORD: example
          MYSQL_USER: user
          MYSQL_PASSWORD: pass

      adminer:
        image: adminer
        restart: always
        ports:
          - 8080:8080

答案 1 :(得分:0)

用于存储密码的哈希可能存在问题。 adminer使用的mysql客户端可能不兼容 使用最新的mysql版本。

尝试在docker-compose.yml中固定正确的版本,并确保adminer容器支持使用的mysql版本。 (重要:即使Adminer支持最新的MySQL版本,容器也可能使用旧的MySQL客户端)

hub.docker.com中针对adminer的示例显示,他们将mysql固定为5.6。您可以尝试这样做以检查您的设置是否有效。 (https://hub.docker.com/_/adminer/