1 Replies - 262 Views - Last Post: 11 March 2019 - 09:52 AM Rate Topic: -----

#1 lfrost2015   User is offline

  • D.I.C Head

Reputation: 0
  • View blog
  • Posts: 53
  • Joined: 08-March 15

Symfony MySQL Database Connection error

Posted 09 March 2019 - 06:33 AM

I'm doing a project using the Symfony framework (version 4) and as I have tried to create a database as well as making migrations, this error appears:

  SQLSTATE[HY000] [1045] Access denied for user 'root'@'localhost' (using password: NO) 


I've had a look online and one of the suggestions was to change the .env file for the database details which I did but the error still appears?

.env file:

###> symfony/framework-bundle ###
APP_ENV=dev
APP_SECRET=e8eef741058ee9f61e730a0cd6601ea0
#TRUSTED_PROXIES=127.0.0.1,127.0.0.2
#TRUSTED_HOSTS='^localhost|example\.com$'
###< symfony/framework-bundle ###

###> doctrine/doctrine-bundle ###
# Format described at http://docs.doctrine-project.org/projects/doctrine-dbal/en/latest/reference/configuration.html#connecting-using-a-url
# For an SQLite database, use: "sqlite:///%kernel.project_dir%/var/data.db"
# Configure your db driver and server_version in config/packages/doctrine.yaml
DATABASE_URL="mysql://root:@127.0.0.1:3306/db"
###< doctrine/doctrine-bundle ###

###> symfony/swiftmailer-bundle ###
# For Gmail as a transport, use: "gmail://username:[email protected]"
# For a generic SMTP server, use: "smtp://localhost:25?encryption=&auth_mode="
# Delivery is disabled by default via "null://localhost"
MAILER_URL=null://localhost
###< symfony/swiftmailer-bundle ###




With or without the database password it still doesn't work even when the database details are changed so was wondering about what the solution is to this?

Is This A Good Question/Topic? 0
  • +

Replies To: Symfony MySQL Database Connection error

#2 ArtificialSoldier   User is online

  • D.I.C Lover
  • member icon

Reputation: 2282
  • View blog
  • Posts: 6,971
  • Joined: 15-January 14

Re: Symfony MySQL Database Connection error

Posted 11 March 2019 - 09:52 AM

The solution for "access denied" is to use the correct database user and password.
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1