Denis Rd
Denis Rd

Reputation: 61

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)

parametrs.yml:

This file is auto-generated during the composer install

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

My OS is Debian

Thanks for your help.

[mysqld_safe]
socket      = /var/run/mysqld/mysqld.sock
nice        = 0

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

Upvotes: 5

Views: 147799

Answers (6)

Eric Atinga
Eric Atinga

Reputation: 29

This basically means that either your username incorrect or your password is incorrect. Please countercheck and make sure you are using the correct password

Upvotes: 3

Đặng Việt Anh
Đặng Việt Anh

Reputation: 1

write direct password into config>database.php

'password' => env('DB_PASSWORD', '')

Change to

'password' => 'your password',

Upvotes: 0

Mitan
Mitan

Reputation: 11

I'm Using Xampp and Laravel 5.8 in Windows 10, and i've been like this before. When i got this problem, My XAMPP is no have Password Then I tried to delete some codes in config>database.php

'password' => env('DB_PASSWORD', ''),

And in .env

DB_PASSWORD=SECRET

the Problem is solved

Upvotes: 1

Samuel Jr Fredrick
Samuel Jr Fredrick

Reputation: 11

'default' => env('DB_CONNECTION', 'mysql'),

add this in your code

Upvotes: 1

Melroy van den Berg
Melroy van den Berg

Reputation: 3215

database_password: password would between quotes: " or '.

like so:

database_password: "password"

Upvotes: 5

DerStoffel
DerStoffel

Reputation: 2633

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 DATABASE sgce;

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

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

database_port: 3306

Upvotes: 8

Related Questions