MySQL in Docker returns "The server requested authentication method unknown to the client" MySQL in Docker returns "The server requested authentication method unknown to the client" docker docker

MySQL in Docker returns "The server requested authentication method unknown to the client"


just update your docker-compose file as given below and rebuild the image.

 mysql:    image: mysql    command: --default-authentication-plugin=mysql_native_password    container_name: sf4_mysql    volumes:        - .docker/data/db:/var/lib/mysql    environment:        MYSQL_ROOT_PASSWORD: root        MYSQL_DATABASE: ***        MYSQL_USER: ***        MYSQL_PASSWORD: ***


MySQL 8.0 uses "Pluggable Authentication" - You can solve the issue by taking the following steps.

  1. Open your my.cnf and add the following entry (and restart MySQL)

    [mysqld]

    default_authentication_plugin=mysql_native_password

  2. Create a user (your MYSQL_USER name) using the correct 8.0 syntax for generating the password (see below)

    IDENTIFIED WITH mysql_native_password

Flush the pivileges and try again. That should do the trick.