Reputation: 539
I have a Symfony 4 application which connects to a local MySQL instance. It is running totally fine in the application and also while using console commands for doctrine. Suddenly, even though nothing has changed in my db configuration (and my mysql instance is running) i am getting this error:
SQLSTATE[HY000] [1045] Access denied for user 'root'@'localhost' (using password: NO)
when i run:
php bin/console doctrine:schema:update --force
However my connection in the app works perfectly fine! The same command was working totally fine just an hour ago. I know there are many questions asked about this problem already but the answers do not apply to me. I am under time pressure right now to finish a project and this is driving me crazy.
This is my .env configuration:
DB_USER=root
DB_PASSWORD=root
DB_HOST=localhost
DB_PORT=3306
DB_NAME=test DATABASE_URL=mysql://${DB_USER}:${DB_PASSWORD}@${DB_HOST}:${DB_PORT}/${DB_NAME}
and my doctrine.yaml config looks like this:
parameters:
# Adds a fallback DATABASE_URL if the env var is not set.
# This allows you to run cache:warmup even if your
# environment variables are not available yet.
# You should not need to change this value.
env(DATABASE_URL): ''
doctrine:
dbal:
# configure these for your database server
driver: 'pdo_mysql'
server_version: '5.7'
charset: utf8mb4
default_table_options:
charset: utf8mb4
collate: utf8mb4_unicode_ci
url: '%env(resolve:DATABASE_URL)%'
mapping_types:
enum: string
orm:
auto_generate_proxy_classes: true
naming_strategy: doctrine.orm.naming_strategy.underscore
auto_mapping: true
mappings:
App:
is_bundle: false
type: annotation
dir: '%kernel.project_dir%/src/Entity'
prefix: 'App\Entity'
alias: App
Upvotes: 1
Views: 1332
Reputation: 539
I solved this issue by changing the charset and collation in doctrine.yaml to another more general utf8 one. I didn't change it the entire time until then and it worked with it before so i have no idea why it suddenly decided in one part of the application its not good enough.
Upvotes: 1