You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I'm on a Macbook Air M2 2022 and i'm trying to create the database with MySQL instead of PostgreSQL, but when i run:
docker compose exec php bin/console dbal:run-sql -q "SELECT 1"&&echo"OK"||echo"Connection is not working"
I get:
In ExceptionConverter.php line 101:
An exception occurred in the driver: SQLSTATE[HY000] [2002] php_network_getaddresses: getaddrinfo for database failed: Name or service not known
...
Connection is not working.
And sometimes this:
Error response from daemon: Container <container_id> is restarting, wait until the container is running
Connection is not working
If i run:
docker-compose logs database
i get:
Creating a "symfony/skeleton " project at "./tmp"
container_name-database-1 |
container_name-database-1 | In CreateProjectCommand.php line 388:
container_name-database-1 |
container_name-database-1 | Invalid stability provided (), must be one of: stable, RC, beta, alpha, dev
These are my edits from PostgreSQL, I followed the guide of this project obviously: Using MySQL
In my Dockerfile i added this line:
RUN install-php-extensions pdo_mysql
In compose.yaml
services:
php:
image: ${IMAGES_PREFIX:-}app-phprestart: unless-stoppedenvironment:
SERVER_NAME: ${SERVER_NAME:-localhost}, php:80MERCURE_PUBLISHER_JWT_KEY: ${CADDY_MERCURE_JWT_SECRET:-!ChangeThisMercureHubJWTSecretKey!}MERCURE_SUBSCRIBER_JWT_KEY: ${CADDY_MERCURE_JWT_SECRET:-!ChangeThisMercureHubJWTSecretKey!}TRUSTED_PROXIES: ${TRUSTED_PROXIES:-127.0.0.0/8,10.0.0.0/8,172.16.0.0/12,192.168.0.0/16}TRUSTED_HOSTS: $${TRUSTED_HOSTS:-^$${SERVER_NAME:-example\.com|localhost}|php$$}# Run "composer require symfony/orm-pack" to install and configure Doctrine ORMDATABASE_URL: mysql://${MYSQL_USER:-app}:${MYSQL_PASSWORD:-root_psw}@database:3306/${MYSQL_DATABASE:-app}?serverVersion=${MYSQL_VERSION:-8}&charset=${MYSQL_CHARSET:-utf8mb4}# Run "composer require symfony/mercure-bundle" to install and configure the Mercure integrationMERCURE_URL: ${CADDY_MERCURE_URL:-http://php/.well-known/mercure}MERCURE_PUBLIC_URL: $${CADDY_MERCURE_PUBLIC_URL:-https://$${SERVER_NAME:-localhost}/.well-known/mercure}MERCURE_JWT_SECRET: ${CADDY_MERCURE_JWT_SECRET:-!ChangeThisMercureHubJWTSecretKey!}# The two next lines can be removed after initial installationSYMFONY_VERSION: ${SYMFONY_VERSION:-}STABILITY: ${STABILITY:-stable}volumes:
- caddy_data:/data
- caddy_config:/configports:
# HTTP
- target: 80published: ${HTTP_PORT:-80}protocol: tcp# HTTPS
- target: 443published: ${HTTPS_PORT:-443}protocol: tcp# HTTP/3
- target: 443published: ${HTTP3_PORT:-443}protocol: udp# Mercure is installed as a Caddy module, prevent the Flex recipe from installing another service###> symfony/mercure-bundle ######< symfony/mercure-bundle ######> doctrine/doctrine-bundle ###database:
image: mysql:${MYSQL_VERSION:-8}environment:
MYSQL_DATABASE: ${MYSQL_DATABASE:-app}# You should definitely change the password in productionMYSQL_RANDOM_ROOT_PASSWORD: "true"MYSQL_PASSWORD: ${MYSQL_PASSWORD:-root_psw}MYSQL_USER: ${MYSQL_USER:-app}healthcheck:
test: ["CMD", "mysqladmin" ,"ping", "-h", "localhost"]timeout: 5sretries: 5start_period: 60svolumes:
- database_data:/var/lib/mysql:rw# You may use a bind-mounted host directory instead, so that it is harder to accidentally remove the volume and lose all your data!# - ./docker/db/data:/var/lib/mysql:rw###< doctrine/doctrine-bundle ###volumes:
caddy_data:
caddy_config:
###> symfony/mercure-bundle ######< symfony/mercure-bundle ######> doctrine/doctrine-bundle ###database_data:
###< doctrine/doctrine-bundle ###
In compose.override.yaml:
# Development environment overrideservices:
php:
build:
context: .target: frankenphp_devvolumes:
- ./:/app
- ./frankenphp/Caddyfile:/etc/caddy/Caddyfile:ro
- ./frankenphp/conf.d/app.dev.ini:/usr/local/etc/php/conf.d/app.dev.ini:ro# If you develop on Mac or Windows you can remove the vendor/ directory# from the bind-mount for better performance by enabling the next line:#- /app/vendorenvironment:
MERCURE_EXTRA_DIRECTIVES: demo# See https://xdebug.org/docs/all_settings#modeXDEBUG_MODE: "${XDEBUG_MODE:-off}"extra_hosts:
# Ensure that host.docker.internal is correctly defined on Linux
- host.docker.internal:host-gatewaytty: true###> symfony/mercure-bundle ######< symfony/mercure-bundle ######> doctrine/doctrine-bundle ###database:
ports:
- "3306"###< doctrine/doctrine-bundle ###
and the .env file:
# In all environments, the following files are loaded if they exist,# the latter taking precedence over the former:## * .env contains default values for the environment variables needed by the app# * .env.local uncommitted file with local overrides# * .env.$APP_ENV committed environment-specific defaults# * .env.$APP_ENV.local uncommitted environment-specific overrides## Real environment variables win over .env files.## DO NOT DEFINE PRODUCTION SECRETS IN THIS FILE NOR IN ANY OTHER COMMITTED FILES.# https://symfony.com/doc/current/configuration/secrets.html## Run "composer dump-env prod" to compile .env files for production use (requires symfony/flex >=1.2).# https://symfony.com/doc/current/best_practices.html#use-environment-variables-for-infrastructure-configuration###> symfony/framework-bundle ###APP_ENV=devAPP_SECRET=65efaf30cc8461feb7b8a398bc16fda9###< symfony/framework-bundle ######> doctrine/doctrine-bundle #### Format described at https://www.doctrine-project.org/projects/doctrine-dbal/en/latest/reference/configuration.html#connecting-using-a-url# IMPORTANT: You MUST configure your server version, either here or in config/packages/doctrine.yaml## DATABASE_URL="sqlite:///%kernel.project_dir%/var/data.db"# DATABASE_URL="mysql://app:[email protected]:3306/app?serverVersion=8.0.32&charset=utf8mb4"# DATABASE_URL="mysql://app:[email protected]:3306/app?serverVersion=10.11.2-MariaDB&charset=utf8mb4"DATABASE_URL=mysql://${MYSQL_USER:-app}:${MYSQL_PASSWORD:-root_psw}@database:3306/${MYSQL_DATABASE:-app}?serverVersion=${MYSQL_VERSION:-8}&charset=${MYSQL_CHARSET:-utf8mb4}###< doctrine/doctrine-bundle ###
What can i do to fix this? I seem to be configuring everything correctly.
Thanks in advance!
The text was updated successfully, but these errors were encountered:
It looks like Doctrine returns a 255 status code when failing to connect to MySQL. It's not the case for Postgres. Maybe should we tweak or comment this check?
It looks like Doctrine returns a 255 status code when failing to connect to MySQL. It's not the case for Postgres. Maybe should we tweak or comment this check?
Might also be a good idea to mentioned it somewhere in docs/mysql.md.
I've been looking into it, and it seems like the 2002Connection refused exception code is converted to 255 by Symfony\Component\Console\Applicationhere. Seems like it has to do with the inner workings of the Database Driver being used: what error codes are returned, and how it's being converted into an exception (and whether the error code is set as the Exception code).
Anyway, safe to say it's probably not ideal to use the 255 exit code as a way of identifying failure states unrelated to the database health check. I don't have any immediate alternatives though, only thing that comes to mind is to wrap the dbal:run-sql in a custom command.
Hi everyone!
I'm on a Macbook Air M2 2022 and i'm trying to create the database with MySQL instead of PostgreSQL, but when i run:
I get:
And sometimes this:
If i run:
i get:
These are my edits from PostgreSQL, I followed the guide of this project obviously: Using MySQL
Dockerfile
i added this line:RUN install-php-extensions pdo_mysql
In
compose.yaml
In
compose.override.yaml
:and the
.env
file:What can i do to fix this? I seem to be configuring everything correctly.
Thanks in advance!
The text was updated successfully, but these errors were encountered: