Denis Rd Denis Rd - 1 year ago 94
PHP Question

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

When I try to login I get an error:

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


This file is auto-generated during the composer install

database_driver: pdo_mysql
database_host: localhost
database_port: null
database_name: sgce
database_user: root
database_password: mikem
mailer_transport: smtp
mailer_user: null
mailer_password: null
locale: en
secret: ThisTokenIsNotSoSecretChangeIt

My OS is Debian

Thanks for your help.

socket = /var/run/mysqld/mysqld.sock
nice = 0

# * Basic Settings
user = mysql
pid-file = /var/run/mysqld/
socket = /var/run/mysqld/mysqld.sock
port = 3306
basedir = /usr
datadir = /var/lib/mysql
tmpdir = /tmp
lc-messages-dir = /usr/share/mysql
# Instead of skip-networking the default is now to listen only on
# localhost which is more compatible and is not less secure.
#bind-address =
bind-address =

Answer Source

This is due to your mysql configuration. According to this error you are trying to connect with the user 'root' to the database host 'localhost' on a database namend 'sgce' without being granted access rights.

Presuming you did not configure your mysql instance. Log in as root user and to the folloing:


CREATE USER 'root'@'localhost' IDENTIFIED BY 'mikem';
GRANT ALL PRIVILEGES ON sgce. * TO 'root'@'localhost';

Also add your database_port in the parameters.yml. By default mysql listens on 3306:

database_port: 3306