Sqlstate[Hy000] [1045] Access Denied for User 'Root'@'Localhost' (Using Password: No)

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

Make sure your database credentials and database host are set correctly:

DB_CONNECTION=mysql
DB_HOST=127.0.0.1
DB_PORT=3306
DB_DATABASE="your_database_name"
DB_USERNAME="put_db_user_name _here"
DB_PASSWORD="put_db_password_here_if_have_set"

If you have not set any database password then add:

DB_PASSWORD=""

SQLSTATE[HY000] [1045] Access denied for user 'root'@'localhost' (using password: NO) (SQL: select * from `permissions`)

Multiple reasons can be the cause.

  1. This can happen when the server has already been started before updating database details on your .ENV file.
  2. It could also be from inputting wrong database authentication details.

Solution

  1. Restart the server anytime you update values on your .ENV file.
  2. Ensure you use the correct authentication details or better still create a new database user.

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

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

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

(@Suleman and @John Lobo, can you make an answer so that I can rate it as correct?!)

It's just php artisan config:cache after some changes at .env and database.php (like @John Lobo said)

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

The solution:

Sometimes when you change your .env, the configs don't refresh without clear cache or restarting the server.

The error message are:

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

The database are trying to get the information from the "cached" .env configuration, you should try:

php artisan config:clear

if not solve, restart your server.

[Edit] Another NON RECOMMENDED option:

  • Go to your config\database.php
  • remove the .env configuration

And set your own credentials

'mysql' => [
'host' => '45.55.88.77',
'database' => 'prod',
'username' => 'forge',
'password' => '*********',
],


Related Topics



Leave a reply



Submit