无法加载插件 caching_sha2_password:/mariadb19/plugin/caching_sha2_password.so:无法打开共享对象文件

Ken*_*Ken 5 mysql linux django docker

我正在尝试 dockerise 我的 Django 应用程序。

docker-compose.yml

version: "3.8"

services:
  db:
    image: mysql:8
    command: --default-authentication-plugin=mysql_native_password # this is not working
    restart: always
    environment:
      MYSQL_ROOT_PASSWORD: rootmypass
    ports:
      - '3306:3306'
  cache:
    image: redis
    environment:
      REDIS_HOST: localhost
      REDIS_PORT: 6379
    ports:
      - '6379:6379'
  web:
    build: .
    command: python manage.py runserver 0.0.0.0:8000
    volumes:
      - .:/code
    ports:
      - "8000:8000"
    depends_on:
      - db
      - cache
Run Code Online (Sandbox Code Playgroud)

当我运行时docker-compose -up,出现以下错误。

django.db.utils.OperationalError: (1156, 'Plugin caching_sha2_password could not be loaded: /usr/lib/x86_64-linux-gnu/mariadb19/plugin/caching_sha2_password.so: cannot open shared object file: No such file or directory')
Run Code Online (Sandbox Code Playgroud)

经过搜索,我发现解决方案是使用command: --default-authentication-plugin=mysql_native_password或降级mysql。尝试了第一个命令,但它不起作用。我也不想降级。

我如何让它工作?

额外细节:

  • 在 Windows 上使用 Docker。
  • 发行版:Ubuntu 20.04 LTS (WSL2)。
  • 连接器:mysqlclient==1.4.6。

Ken*_*Ken 2

停止容器使用docker-compose down然后重新启动它们就可以了。在此之前我使用的是 CTRL + C。

  • 但这对我没有帮助 (7认同)