laradock mysql8.0 connection problem

laradock mysql8.0 connection problem

By default, laradock uses mysql latest image to build mysql service. As a result, mysql 8.0 is used and caching_sha2_password authentication plugin is the default configuration.

When phpmyadmin tries to connect mysql service, error occurs:

#2054 - The server requested authentication method unknown to the client
mysqli_real_connect(): The server requested authentication method unknown to the client [caching_sha2_password]
mysqli_real_connect(): (HY000/2054): The server requested authentication method unknown to the client

The root cause is phpmyadmin still uses mysql_native_password to connect mysql.

So to solve this problem elegantly, one of the way is to change mysql service to use mysql_native_password authentication plugin.

I tried modifying laradock’s docker-compose.yml to fix this problem.

### MySQL ################################################
    mysql:
      build:
      ...
      command: 
        --default-authentication-plugin=mysql_native_password

remove the generated mysql container and image, rebuild them from scratch. And it will work.

Other ways may be changing mysql’s dockerfile or changing mysql’s my.cnf file.

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.