Access denied for user 'mysuer'@'localhost' (MySQL)

Hi all:

(v2026)

I know all the post with this subject have been solved checking the right user and password for the database.

My VPS server have been working while in debug mode, but when I compile in Production mode, the user and password to the db stop working.

But I’ve changed my database user and password and set them in .env.prod.local (project recreated with Enviroment = Production)
I can access my database with phpMyAdmin, with heidisql, and from mysql console with the same credentials I’ve set in .env.prod.local. I’ve cleared cache, restarted my VPS, but nothing works…

I always get this error in the log:

request.CRITICAL: Uncaught PHP Exception Doctrine\DBAL\Exception\ConnectionException: "An exception occurred while executing a query: SQLSTATE[28000]: Invalid authorization specification: 1045 Access denied for user 'mysuer'@'localhost' (using password: YES)" at ExceptionConverter.php line 91 {"exception":"[object] (Doctrine\DBAL\Exception\ConnectionException(code: 1045): An exception occurred while executing a query: SQLSTATE[28000]: Invalid authorization specification: 1045 Access denied for user 'myuser'@'localhost' (using password: YES) at /home/semi/web/domain.com/public_html/vendor/doctrine/dbal/src/Driver/API/MySQL/ExceptionConverter.php:91)\n
[previous exception] [object] (Doctrine\DBAL\Driver\PDO\Exception(code: 1045): SQLSTATE[28000]: Invalid authorization specification: 1045 Access denied for user 'myuser'@'localhost' (using password: YES) at /home/semi/web/domain.com/public_html/vendor/doctrine/dbal/src/Driver/PDO/Exception.php:24)\n[previous exception] [object] (PDOException(code: 28000): SQLSTATE[28000]: Invalid authorization specification: 1045 Access denied for user 'myuser'@'localhost' (using password: YES) at /home/semi/web/domain.com/public_html/vendor/doctrine/dbal/src/Driver/PDO/Connection.php:57)"}

DB_DRIVER=pdo_mysql
DB_HOST=localhost
DB_PORT=3306
DB_DBNAME=mydb
DB_USER=myuser
DB_PASSWORD=mypasswordhere
DB_CHARSET=utf8mb4

It’s funny, if I set my first user and password, my web works.

  1. Make sure you have upload the .env file (which specifies your environment, e.g. APP_ENV=prod).
  2. Double check your user name and password in the .env.prod.local. (If both dev/prod use "myuser" as username, you cannot determine from the error message if your app is reading the correct file, i.e. .env.prod.php. Double check.)
  3. Clearing Symfony Cache, make sure you clear the cache for the correct environment (i.e. var/cache/prod). To be sure, you may clear both.