docker-compose mysql Access denied for user [email protected]’172.18.0.1′

I have a DB issue while running a Symfony4 project.

docker-compose.yml

db:
    environment:
      MYSQL_DATABASE: ${DATABASE_NAME}
      MYSQL_PASSWORD: ${DATABASE_PASSWORD}
      MYSQL_RANDOM_ROOT_PASSWORD: 'yes'
      MYSQL_USER: ${DATABASE_USERNAME}
    image: 'mariadb/server:10.4'
    ports:
      - '3306:3306'
    volumes:
      - 'db-data:/var/lib/mysql'

.env

DATABASE_URL=mysql://symfony:[email protected]/symfony
###< doctrine/doctrine-bundle ###
DB_HOST=db.localhost
DB_NAME=symfony
DB_USERNAME=symfony
DB_PASSWORD=symfony
DATABASE_PORT=3306
DATABASE_HOST=db.localhost
DATABASE_USERNAME=symfony
DATABASE_PASSWORD=symfony
DATABASE_NAME=symfony
DATABASE_PORT=3306
PROJECT_NAME=oversight-api

I got an error Access denied for user [email protected]
I am not sure what the 172.18.0.1. Should I add db.localhost to /etc/hosts?

How to solve this issue?

Source: Symfony4 Questions

Was this helpful?

0 / 0

Leave a Reply 0

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