8

I am trying to dockerise my Django app.

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

When I run docker-compose -up, I get the following error.

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')

Upon searching, I found the solution was to use command: --default-authentication-plugin=mysql_native_password or downgrade mysql. Tried the first command but it's not working. I don't want to downgrade as well.

How do I get it to work?

Additional details:

  • Using Docker on Windows.
  • Distro: Ubuntu 20.04 LTS (WSL2).
  • Connector: mysqlclient==1.4.6.
Ken
  • 859
  • 2
  • 14
  • 33
  • What distro are you running the web container as? What mariadb-client libraries are installed in this container? – danblack Oct 15 '20 at 10:11
  • @danblack, updated. I am also a bit confused here why it shows mariadb19 when the image specified is mysql. – Ken Oct 15 '20 at 10:19
  • mariadb19, is from the collection of client libraries provided by Ubuntu focal - https://packages.ubuntu.com/focal/amd64/libmariadb3/filelist is the package. Debian fixed this recently - https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=962597. This is available in MariaDB-10.3, however a ubuntu bug should be raised to include it. – danblack Oct 15 '20 at 10:29
  • otherwise, [change the existing authentication by connecting to the database](https://stackoverflow.com/questions/52864853/how-to-get-mysql-8-to-run-with-laravel/52865317#52865317) – danblack Oct 15 '20 at 10:31
  • Found the issue @danblack, I was using ctrl+c instead of `docker-compose -down`. – Ken Oct 15 '20 at 10:35

2 Answers2

2

Stopping the container using docker-compose down and then restarting them did the trick. I was using CTRL + C prior to that.

Philipp Kyeck
  • 18,402
  • 15
  • 86
  • 123
Ken
  • 859
  • 2
  • 14
  • 33
0

your error is showing you require mariadb plugin. Please verify again

nilay shah
  • 61
  • 3