I have the following mysql service in docker-compose.
services:
db-mysql:
image: mysql
volumes:
- C:\Users\svirl\Documents\workspace\docker\app\db:/docker-entrypoint-initdb.d
env_file:
- app/mysql.env
ports:
- 3306:32787
and in mysql.env this vars:
MYSQL_DATABASE_NAME=app
MYSQL_USER_NAME=app_user
MYSQL_PASSWORD=test123
MYSQL_ROOT_PASSWORD=root123
The problem is the user app_user
with the password test123
and the database app
are not yet created when the initdb.d is parsed and the query will fail at line.
USE app; //database does not exist
A solution would be to manually create that user and database but I don’t wan’t this, I want to use that mysql.env file.
So what would be the solution for this?