I’m encountering a database connection issue in my newly hosted Laravel 11 application on Hostinger. I’ve carefully configured the files and database in phpMyAdmin, but I’m getting this error:
SQLSTATE[HY000] [1045] Access denied for user ‘root’@’127.0.0.1’ (using password: NO)
this is my .env
file configuration:
DB_CONNECTION=mysql
DB_HOST=127.0.0.1
DB_PORT=3306
DB_DATABASE=myDataBase
DB_USERNAME=MyUserName
DB_PASSWORD=ThaPassWord
DB_COLLATION=utf8mb4_unicode_ci
2
Answers
check Hostinger panel for managing database or hostinger – How to Create a New MySQL Database
create user for your database and fill that credentials in your env file. Currently your app tries to use database as root without password which is a big NO.
This is work for me:
Even though I changed the config details in the .env file, I was getting the Access denied error. Running the above command will clear configuration cache file and hence laravel will read the fresh data from the .env file