postgresqlphppgadmin

Why I can not login into phppgadmin with postgres user?


I installed phppgadmin (Version: 7.12.1+dfsg-1) under ubuntu of my home laptop and in file /etc/phppgadmin/config.inc.php I replaced parameter

$conf['extra_login_security'] = false;

and restarted services postgresql and apache2

Next failed to enter into it by url

http://localhost/phppgadmin/

I entered “postgres” both for use and password(I suppose that is login by default) but got invalid login.

I tried to replace password with command

root@ubuntu:~# passwd postgres

But entering new password in phppgadmin I got invalid login.

In last line of command :

cat /etc/passwd 

I see: ...

postgres:x:129:138:PostgreSQL administrator,,,:/var/lib/postgresql:/bin/bash

How can I restore postgres password and get access to phppgadmin ?

MODIFIED 1 :

I check postgresql status and try to enter into postgresql console :

root@hoster-os:/ProjectPath/# sudo service postgresql status
● postgresql.service - PostgreSQL RDBMS
     Loaded: loaded (/lib/systemd/system/postgresql.service; enabled; vendor preset: enabled)
     Active: active (exited) since Sat 2022-07-23 17:13:18 EEST; 4min 13s ago
    Process: 34804 ExecStart=/bin/true (code=exited, status=0/SUCCESS)
   Main PID: 34804 (code=exited, status=0/SUCCESS)

Jul 23 17:13:18 hoster-os systemd[1]: Starting PostgreSQL RDBMS...
Jul 23 17:13:18 hoster-os systemd[1]: Finished PostgreSQL RDBMS.
root@hoster-os:/ProjectPath/# psql
psql: error: FATAL:  role "root" does not exist

where hoster-os - my os name.

$  echo $USER
hoster

Solution

  • PostgreSQL has its own password system, changing the OS password for a OS user named 'postgres' has no effect on the PostgreSQL password for the PostgreSQL user also spelled 'postgres'. (You can change that situation by configuring PostgreSQL to use pam module and tying that to the OS auth system, but that is rarely done and certainly not the default).

    Also, it has been a long time since password hashes were stored in /etc/passwd, they are now stored in /etc/shadow, which is not world readable. But that is not actually relevant here, because see previous paragraph.

    I don't know of any general purpose PostgreSQL installer that sets a default password. They either prompt you to set one upon installation, or they configure it to initially use some other authentication method (like 'peer') for local connections and then you need to make desired changes yourself (including assigning a password from within the system)

    sudo service postgresql status isn't very useful, you need to look in the log file to get any real information.

    'root' might exist as a OS user but not by default as a PostgreSQL user, hence the last error message. You either need to tell psql what user to use like psql -U postgres, or you need to turn yourself into the OS user named 'postgres' before running psql, like sudo -u postgres psql. If it is configured to use simple peer authentication, then you need to use the 2nd of those, the 1st will just fail with a different error message