Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

docker-compose : The server requested authentication method unknown to the client

I have this yml file for configuration of MySQL in docker:

# Use root/example as user/password credentials
version: '3.1'

services:

  db:
    image: mysql
    restart: always
    environment:
       MYSQL_ROOT_PASSWORD: 'pass'
       MYSQL_DATABASE: 'db'
       MYSQL_USER: 'user'
       MYSQL_PASSWORD: 'pass'

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

And I start the container using following command from the same directory where yml is located:

docker-compose -f stack.yml up

Then I got this error:

then i get following error while logging in

like image 510
Navin Gelot Avatar asked Apr 30 '18 08:04

Navin Gelot


People also ask

How do I fix Sqlstate hy000 2054 the server requested authentication method unknown to the client?

UPDATE `mysql`. `user` SET `plugin` = 'mysql_native_password' WHERE (`Host` = 'YOUR MATOMO DB HOST NAME') and (`User` = 'YOUR MATOMO DB USER NAME'); or alternatively: 2) Create a new database and database user in MySQL by running the SQL queries from this FAQ, and then update your matomo/config/config.

What is Mysql_native_password?

The mysql_native_password authentication plugin is the default authentication plugin that will be used for an account created when no authentication plugin is explicitly mentioned and old_passwords=0 is set.

What is Auth_socket?

The auth_socket plugin checks whether the socket user name matches the MySQL user name specified by the client program to the server. If the names do not match, the plugin also checks whether the socket user name matches the name specified in the authentication_string column of the mysql. user table row.


1 Answers

If you encounter this error but still wish to use MySQL v.8. You can do this by telling MySQL Server to use the legacy authentication plugin.

So, your compose file will look like this:

# Use root/example as user/password credentials

version: '3.1'

services:

  db:
    image: mysql
    command: --default-authentication-plugin=mysql_native_password
    restart: always
    environment:
       MYSQL_ROOT_PASSWORD: 'pass'
       MYSQL_DATABASE: 'db'
       MYSQL_USER: 'user'
       MYSQL_PASSWORD: 'pass'

  adminer:
    image: adminer
    restart: always
    ports:
      - 8888:8080
like image 159
hatef Avatar answered Sep 19 '22 11:09

hatef