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

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

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

SQLSTATE[HY000] [2002] Connection refused |

I'm using MAC OS and I'm new to laravel .. I'm working on laravel using xampp and when i run the command php artisan migrate
I get this error
SQLSTATE[HY000] [2002] Connection refused (SQL: select * from information_schema.tables where table_schema = web and table_name = migrations and table_type = 'BASE TABLE')
my .env
DB_CONNECTION=mysql
DB_HOST=127.0.0.1
DB_PORT=3306
DB_DATABASE=web
DB_USERNAME=root
DB_PASSWORD=
I searched and tried most of the ways and it is still not working unfortunately
Try the methods below:
open your .env file and change DB_HOST = 127.0.0.1 to localhost
try restarting your localhost server (xampp)
try downgrading your xampp to a lower version

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

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

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)

Resources