Php connection docker mysql 8.0 error authentication method unknown

< H2 > complete error: < / H2 >
SQLSTATE[HY000] [2054] The server requested authentication method unknown to the client
< H2 > docker-compose.xml < / H2 >
mysql:
    image: mysql:8.0
    volumes:
      - ./mysql/data:/var/lib/mysql
      - ./mysql/my.cnf:/etc/mysql/conf.d/my.cnf
    ports:
      - 3306:3306
    env_file:
      - ./.env
< H2 > my.cnf < / H2 >
innodb_buffer_pool_size = 16M
innodb_additional_mem_pool_size = 2M
innodb_log_file_size = 5M
innodb_log_buffer_size = 8M

PHP version 7.1

Feb.12,2022

read the document for yourself. The new verification method Caching SHA-2
so add a sentence to my.cnf:

default_authentication_plugin=mysql_native_password

change to the original verification method


this problem is caused by the incompatibility between the new mysql account password unlocking mechanism and the old one. You check your user, if the password is 16 digits, it is the old account, you need to reset the new password.

SELECT
  Length(`Password`),
  Substring(`Password`, 1, 1)
FROM
  `mysql`.`user`
WHERE
  `user`='' // 

has it been solved, landlord?

Menu