I have uploaded a Laravel project in my cPanel. It gives the following error
SQLSTATE[HY000] [1044] Access denied for user ‘amartuki_finance’@’localhost’ to database ‘amartuki_finance’
But I have change my .env
file’s db name,user and password. Also configure in config/database.php
file.
.env
file
DB_CONNECTION=mysql
DB_HOST=127.0.0.1
DB_PORT=3306
DB_DATABASE=amartuki_finance
DB_USERNAME=amartuki_finance
DB_PASSWORD=amartuki_finance
config/database.php
file
'mysql' => [
'driver' => 'mysql',
'host' => env('DB_HOST', '127.0.0.1'),
'port' => env('DB_PORT', '3306'),
'database' => env('DB_DATABASE', 'amartuki_finance'),
'username' => env('DB_USERNAME', 'amartuki_finance'),
'password' => env('DB_PASSWORD', 'amartuki_finance'),
'unix_socket' => env('DB_SOCKET', ''),
'charset' => 'utf8mb4',
'collation' => 'utf8mb4_unicode_ci',
'prefix' => '',
'strict' => false,
'engine' => null,
],
What’s the solution then ! Anybody help please ?
2
Answers
Solved my problem. It's a very silly mistake.
After creating user I didn't add the user to my database and that's why user didn't get any privilege.
Now change those things and the project run successfully.
You should follow following method to load
env
values inLaravel