php服务器请求的客户端身份验证方法未知

时间:2020-08-31 02:53:43

标签: php mysql docker

我通过docker-compose部署了项目。它在本地环境下工作。我试图找到某种方法来解决这个问题。

我知道为什么会这样。由于采用了mysql 8.0+的新验证方法

根据一些文章,已经包含了caching_sha2_password的较新的PHP版本,我的PHP为7.3.21,并检查了Mysqlnd:

Loaded plugins: 
    mysqlnd,debug_trace,auth_plugin_mysql_native_password,
    auth_plugin_mysql_clear_password,auth_plugin_sha256_password

这里没有caching_sha2_password

因此,我尝试更改mysql的默认设置,我编辑了my.cnf并将其安装到/etc/mysql/conf.d中,但它不起作用,我尝试将其安装到/etc/mysql/中,但是也没用。

然后,我尝试修改docker-composer.yml,在正式文档中,我将其添加到了文件command: --default-authentication-plugin=mysql_native_password中。仍然没用。

docker-compose.yml

version: "3.1"
services:
  
  nginx-www-7:
    image: nginx:1.15.12
    restart: always
    ports:
      - "80:80"
    volumes:
      - ./../../../:/usr/share/nginx/html
      - ./nginx/conf.d:/etc/nginx/conf.d
      - ./nginx/log:/var/log/nginx
    links:
      - php-www-7
    depends_on:
      - php-www-7
    networks:
      - net-www-7
    container_name: nginx-www
  
  mysql-www-7:
    image: mysql:8.0
    command: --default-authentication-plugin=mysql_native_password
    restart: always
    environment:
      MYSQL_ROOT_PASSWORD: root
    ports:
      - "3307:3306"
    volumes:
      - ./mysql/datadir:/var/lib/mysql
      - ./mysql/conf.d:/etc/mysql
    networks:
      - net-www-7
    container_name: mysql-www


  php-www-7:
    build:
        context: .
    image: php:www73
    restart: always
    ports:
      - "9001:9000"
      - "9502:9502"
      - "8088:8088"
    volumes:
      - ./../../../:/var/www/html/
      - ./php/cert:/bin/cert
    links:
      - mysql-www-7
      - redis-www-7
    depends_on:
      - mysql-www-7
      - redis-www-7
    networks:
      - net-www-7
    container_name: php-www
    
  redis-www-7:
    image: redis:5.0.5
    restart: always
    ports:
      - "6382:6379"
    volumes:
      - ./redis/datadir:/data
    networks:
      - net-www-7
    container_name: redis-www

networks:
  net-www-7:
    driver: bridge

0 个答案:

没有答案
相关问题