Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Fresh-installation laravel project can't access postgresql database but can do php migrate

I already asked a question about this 2 days ago, here are the links Got "password authentication failed for user" but in pgAdmin 3 its working

But I still didn't get an answer to solve the problem.

So I tried to create a new laravel project, then edit the .env file, check if php artisan migrate can run.

After I run php artisan migrate it's running, so it means that my credentials to PostgreSQL database are correct right? if not it will tell you password authentication failed for user "postgres", but I don't get any error at all, so I go to the next step. Now after I make sure everything is OK i run php artisan make:auth, it's a success without error at all, so I go to the web browser then run the site, I clicked the register / login button, fill the fields, submit then, it's happened again the nightmare

I got this message from the website

SQLSTATE[08006] [7] FATAL: password authentication failed for user "postgres" FATAL: password authentication failed for user "postgres" (SQL: select count(*) as aggregate from "users" where "email" = [email protected])

Even though php artisan migrate run really well, so I've no idea why it's happening. Is there somebody that ever run into this problem before? or maybe why it's happening?

I already search all keywords that possible to fix this problem, but I can't found the answer, it's really stressed me out.

for the info I'm using:

PostgreSQL 9.6.8

Laravel 5.6

Ubuntu 17.10

Edited: Here is my pg_hba.conf

enter image description here

like image 558
Khrisna Gunanasurya Avatar asked Mar 19 '18 09:03

Khrisna Gunanasurya


1 Answers

Check your database.php file in config directory, and check the pgsql array. If accessing DB credential values from .env not worked there, test it by directly putting credentials there. hope it will help. Artisan commands work by accessing the credentials from .env files directly,not from database.php that's why migration worked.

like image 96
Nithin John Avatar answered Oct 23 '22 13:10

Nithin John