"SQLSTATE[HY000] [1045] Access denied for user 'root'#'localhost' : Laravel [duplicate] - laravel

This question already has answers here:
lavaral 5 ERROR{ (SQLSTATE[HY000] [1045] Access denied for user 'root'#'localhost' (using password: YES)}
(2 answers)
Closed 4 years ago.
I am unable to register a user account in a Laravel project.
Error
SQLSTATE[HY000] [1045] Access denied for user 'root'#'localhost' (using password: YES) (SQL: select count(*) as aggregate from `users` where `email` = xxx#xx.com)
Is there a solution?

Make sure that you update the below values in your .env file:
DB_CONNECTION=mysql
DB_HOST=127.0.0.1
DB_PORT=3306
DB_DATABASE=your_database_name
DB_USERNAME=root
DB_PASSWORD=
Once updated .env file, stop the server of your project and serve the project again using the php artisan serve command.

You have to make changes in the .env file for the following fields:
DB_CONNECTION=mysql
DB_HOST=127.0.0.1
DB_PORT=3306
DB_DATABASE= your database name
DB_USERNAME= your user name
DB_PASSWORD= your password

Related

SQLSTATE[HY000] [2002] Connection refused. on SELECT * FROM `users` WHERE `email` = xxxx limit 1

I have setup an existing laravel github project with docker, everything is working fine.
I am getting a connection refused error when trying to login to my backend.
Th exact error is:
Illuminate\ Database\ QueryException
SQLSTATE[HY000] [2002] Connection refused
SELECT * FROM users WHERE email = xxxx limit 1
My .env is:
APP_NAME=Laravel
APP_ENV=local
APP_DEBUG=true
DB_CONNECTION=mysql
DB_HOST=localhost
DB_PORT=3306
DB_DATABASE="xxxxx"
DB_USERNAME="xxxxx"
DB_PASSWORD="xxxxx"

How to Connect to Database SQLSTATE[HY000] [1045] Access denied for user 'root'#'localhost' (using password: YES)

I got this error when i tried to connect to my database:
SQLSTATE[HY000] [1045] Access denied for user 'root'#'localhost' (using password: YES) (SQL: select active_template from general_settings limit 1)
I'm new to laravel so i'm sorry if it's a common question because i try to find the solution and see similar problems but not exactly the same.
I tried to change my .env files and use no pass for the db and restart the server but it is still getting the same error. Here's what my env files look like:
APP_NAME=Laravel
APP_ENV=production
APP_KEY=base64:xxx
APP_DEBUG=true
APP_URL=http://localhost
LOG_CHANNEL=stack
DB_CONNECTION=mysql
DB_HOST=localhost
DB_PORT=3306
DB_DATABASE=database123
DB_USERNAME=root
DB_PASSWORD=
BROADCAST_DRIVER=log
CACHE_DRIVER=file
QUEUE_CONNECTION=sync
SESSION_DRIVER=file
SESSION_LIFETIME=120
REDIS_HOST=127.0.0.1
REDIS_PASSWORD=null
REDIS_PORT=6379
what should i do? thankyou
Try to make another MySQL user, and grant all privileges to ONLY that database. Mostly root user is denied from shared hosting since i check your APP_ENV is on production.
Hope this helpful
https://phoenixnap.com/kb/how-to-create-new-mysql-user-account-grant-privileges
try php artisan config:cache and php artisan cache:clear after changing your .env file

i am facing a problem while migrating database .. using xampp

I don't understand how to fix this problem. what should i do witthon connection.php and connector.php file
In Connection.php line 664:
SQLSTATE[HY000] [1045] Access denied for user 'root'#'localhost'
(using password: YES ) (SQL: select * from information_schema.tables
where table_schema = STDHUB and table _name = migrations)
In Connector.php line 67:
SQLSTATE[HY000] [1045] Access denied for user 'root'#'localhost'
(using password: YES )
It indicates that you're using wrong credentials to connect to MySQL.
Check your MySQL credentials, for example:
username: root
password: secret
Then you should change the value in your .env in your Laravel project folder. If .env does not exist, copy a new one from your .env.example.
DB_USERNAME=root
DB_PASSWORD=secret
Please check DB_User , DB_PWD in your .env file

Connection error with Database in laravel

I am having problem in laravel project connection with database on the live server all credentials are correct in .env and database.php files.
DB_CONNECTION=mysql
DB_HOST=mysql.hostinger.in
DB_PORT=3306
DB_DATABASE=u497405800_new
DB_USERNAME=u497405800_biosp
DB_PASSWORD=bn2OC9IzSop7
ERROR SHOWING:
PDOException in Connector.php line 55: SQLSTATE[HY000] [1045] Access
denied for user 'u497405800_biosp'#'127.0.0.1' (using password: NO)

'PDOException' with message 'SQLSTATE [HY000] [1045]

i do not know why lately when I try to make a regitro in the database (using laravel), I get this error:
'PDOException' with message 'SQLSTATE [HY000] [1045] Access denied for user' homestead '#' localhost '( using password: YES) '.
.env file:
DB_CONNECTION=mysql
DB_HOST=127.0.0.1
DB_PORT=3306
DB_DATABASE=pruebas
DB_USERNAME=root
DB_PASSWORD=
in .env file is properly configured. What more could be ??
thanks.
the solution for this error, if everything is properly configured, is to restart the local server, in my case xampp

Resources