Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

I tried to create my DB with Symfony2 typing the command below:

php app/console doctrine:create:database

The result is:

Could not create database for connection named jobeet SQLSTATE[28000] [1045] Access denied for user 'root'@'localhost' (using password: YES)

The contents of my app/config/parameters.yml file is:

parameters:
   database_driver:   pdo_mysql
   database_host:     127.0.0.1
   database_port:     ~
   database_name:     jobeet
   database_user:     root
   database_password: 0000

   mailer_transport:  smtp
   mailer_host:       127.0.0.1
   mailer_user:       ~
   mailer_password:   ~

   locale:            fr
   secret:            ThisTokenIsNotSoSecretChangeIt

My OS is Ubuntu.

I don't know what to do to correct this problem.

like image 242
mentaga Avatar asked May 01 '13 19:05

mentaga


3 Answers

In your app/config/parameters.yml

# This file is auto-generated during the composer install
parameters:
    database_driver: pdo_mysql
    database_host: 127.0.0.1
    database_port: 3306
    database_name: symfony
    database_user: root
    database_password: "your_password"
    mailer_transport: smtp
    mailer_host: 127.0.0.1
    mailer_user: null
    mailer_password: null
    locale: en
    secret: ThisTokenIsNotSoSecretChangeIt

The value of database_password should be within double or single quotes as in: "your_password" or 'your_password'.

I have seen most of users experiencing this error because they are using password with leading zero or numeric values.

like image 78
Nadun Liyanage Avatar answered Sep 28 '22 05:09

Nadun Liyanage


I dont know what is the exact reason but I solved the problem running:

   app/console cache:clear --env=prod
like image 27
iarroyo Avatar answered Sep 28 '22 06:09

iarroyo


Try to login via the terminal using the following command:

mysql -u root -p

It will then prompt for your password. If this fails, then definitely the username or password is incorrect. If this works, then your database's password needs to be enclosed in quotes:

database_password: "0000"
like image 40
Pier-Luc Gendreau Avatar answered Sep 28 '22 06:09

Pier-Luc Gendreau