Question

Why do I see this issue below during the installation of Magento 2.4?

SQLSTATE[HY000] [2054] The server requested authentication method unknown to the client

Magento 2.4 MySQL

Was it helpful?

Solution

This is happening because of MySQL 8, which by default uses the plugin auth_socket. Applications will most times expect to log in to your database using a password, to do it access the MySQL via root user and run this command:

ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY 'root';  

Then try to connect using it:

mysql -u root -proot

If you are using Docker you can specify it like this example below.

Make sure that you're not using MariaDB to connect into the DB, check it using mysql --version inside your PHP container.

version: '3.7'
services:
db:
    image: mysql:8.0.0
    command: ["--default-authentication-plugin=mysql_native_password"]
    ports:
        - "3306:3306"
    environment:
        MYSQL_ROOT_PASSWORD: root
        MYSQL_USER: magento
        MYSQL_PASSWORD: magento

I fixed it using mysql:5.7.

Licensed under: CC-BY-SA with attribution
Not affiliated with magento.stackexchange
scroll top