php - An exception occurred in driver: SQLSTATE[HY000] [1049] Unknown database 'bitnami_myapp' ← (PHP, Symfony, MySQL, HTML)
I haven't defined a database named bitnami_myapp
anywhere?
My docker-compose.yml
:
version: '2'
services:
myapp:
image: 'docker.io/bitnami/symfony:1-debian-10'
ports:
- '8000:8000'
volumes:
- '.:/app'
depends_on:
- mariadb
mariadb:
image: 'docker.io/bitnami/mariadb:10.3-debian-10'
environment:
- ALLOW_EMPTY_PASSWORD=yes
- MARIADB_USER=andy
- MARIADB_DATABASE=symfony_red
- MARIADB_PASSWORD=password
ports:
- "4307:3306"
My .env
file:-
DATABASE_URL=mysql://andy:password@127.0.0.1:4307/symfony_red?serverVersion=5.7
These are newly installed symfony/bitnami images for: mariadb
and Symfony
service containers.
$ docker-compose up
Steps to recreate:
login to the symfony container
root@b8790e2f3021:/app/myapp#
and run command:
$ bin/console doctrine:migrations:status
receive:
An exception occurred in driver: SQLSTATE[HY000] [1049] Unknown database 'bitnami_myapp'
How do I get symfony/doctrine to use my database defined in docker-compose.yml
rather than looking for: bitnami_myapp
?
Answer
Solution:
Your directory contains some files like .env.local
or .env.dev
or .env.dev.local
.
You should find them, verify and edit their contents.
Here is the chapter of the documentation their priorities.
Source