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.
- This can happen when the server has already been started before updating database details on your .ENV file.
- It could also be from inputting wrong database authentication details.
Solution
- Restart the server anytime you update values on your .ENV file.
- 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
Using Where Clause With Two Type of Conditions on Same Column
How to Select the Last Record of a Table in SQL
Select All Dates Between First Day of Month and Current Date
How to Pass Multiple Values to Single Parameter in Stored Procedure
How to Create Column in SQL Query With Custom Text
Phone Number Display Method, SQL Query
How to Convert from Blob to Text in MySQL
How to Return a Flag If Exist Id in Another Table MySQL
How to Count Number of Digits After a Decimal Place
Mysql: Alter Table If Column Not Exists
Simple Percentage Calculation in MySQL
How to Store the Select Statement Output into Variable Thro Psql ( Postgresql )
Sqlstate[Hy000] [2002] Php_Network_Getaddresses: Getaddrinfo Failed: Name or Service Not Known
Oracle Query to SQL Server Query
How to Connect MySQL Workbench to Running MySQL Inside Docker