0

I tried to test connection using php and database postgresql using below codes: But I got message error like this:

pg_connect(): Unable to connect to postgreSQL server: FATAL: Ident authentication failed for user "postgres"

<?php
     $connect = pg_connect("host=localhost port=5432 dbname=mydb user=postgres password=mypass");
     if(!$connect)
     {
         $error = error_get_last();
         echo $error['message'];
     }
     else
     {
        echo "Connected";
     }
?>

can someone help me please. btw I Using Centos 7.2

towa_ga
  • 11
  • 1
  • 6
  • Can you connect to the database with a tool (f.e. cmd line, pgadmin)? – manuzi1 Dec 11 '17 at 09:47
  • Hi @manuzi1 Thanks for replied, sure I can connect using command. And I also I have added password using this : \password postgres – towa_ga Dec 11 '17 at 10:09
  • Try to check out this answers: https://stackoverflow.com/questions/2942485/psql-fatal-ident-authentication-failed-for-user-postgres – manuzi1 Dec 11 '17 at 10:25

0 Answers0