Mysql error in Magento 2.4 during the authentication
-
14-04-2021 - |
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