diff --git a/docker/compose.override.yaml b/docker/compose.override.yaml index 335505b..828ec7b 100644 --- a/docker/compose.override.yaml +++ b/docker/compose.override.yaml @@ -9,9 +9,6 @@ services: - mailer ###> doctrine/doctrine-bundle ### - database: - ports: - - "3306" ###< doctrine/doctrine-bundle ### ###> symfony/mailer ### diff --git a/docker/compose.yaml b/docker/compose.yaml index 699de9f..1597024 100644 --- a/docker/compose.yaml +++ b/docker/compose.yaml @@ -95,9 +95,10 @@ services: command: ["--default-authentication-plugin=mysql_native_password", "--character-set-server=utf8mb4", "--collation-server=utf8mb4_unicode_ci"] volumes: - database_data:/var/lib/mysql:rw + - ./mysql/init:/docker-entrypoint-initdb.d:ro # Uncomment the two lines below if you need to access MySQL from your host (workbench, etc.) - # ports: - # - "3306:3306" + ports: + - "3306:3306" networks: - backend restart: unless-stopped diff --git a/docker/mysql/init/allow_remote.sql b/docker/mysql/init/allow_remote.sql new file mode 100644 index 0000000..c76299f --- /dev/null +++ b/docker/mysql/init/allow_remote.sql @@ -0,0 +1,15 @@ +-- Grant privileges to the user from any host +-- The MYSQL_USER environment variable in docker-compose usually creates the user with '%' host, +-- but this script ensures it's correctly set for the specific user and database. + +-- Note: We use the actual user and database names defined in our .env files. +-- If you change DB_USER or DB_NAME in .env, you should update them here too if needed, +-- though the Docker image should handle the initial creation correctly. + +CREATE USER IF NOT EXISTS 'escapepage'@'%'; +-- We don't necessarily want to hardcode the password here if we can avoid it, +-- but since it's already in the committed .env.dev, we'll use it for consistency. +ALTER USER 'escapepage'@'%' IDENTIFIED BY 'b.0nqrxJ/D*Luf9N'; +GRANT ALL PRIVILEGES ON `escapepage`.* TO 'escapepage'@'%'; +GRANT ALL PRIVILEGES ON `escapepage_test`.* TO 'escapepage'@'%'; +FLUSH PRIVILEGES;