Su: Authentication failure when trying to fix PostgreSQL failed start error

On a new installation of Manjaro ARM XFCE on a raspberry pi I’m trying to install peertube but I get an error:

[user@pi ~]$ sudo systemctl start redis postgresql
Job for postgresql.service failed because the control process exited with error code.
See "systemctl status postgresql.service" and "journalctl -xeu postgresql.service" for details.
[user@pi ~]$ systemctl status postgresql.service
× postgresql.service - PostgreSQL database server
     Loaded: loaded (/usr/lib/systemd/system/postgresql.service; disabled; vendor preset: disabled)
     Active: failed (Result: exit-code) since Tue 2022-02-15 11:48:06 CET; 19s ago
    Process: 7878 ExecStartPre=/usr/bin/postgresql-check-db-dir ${PGROOT}/data (code=exited, status=1/FAILURE)
        CPU: 246ms

Feb 15 11:48:06 pi systemd[1]: Starting PostgreSQL database server...
Feb 15 11:48:06 pi postgres[7878]: "/var/lib/postgres/data" is missing or empty. Use a command like
Feb 15 11:48:06 pi postgres[7878]:   su - postgres -c "initdb --locale en_US.UTF-8 -D '/var/lib/postgres/data'"
Feb 15 11:48:06 pi postgres[7878]: with relevant options, to initialize the database cluster.
Feb 15 11:48:06 pi systemd[1]: postgresql.service: Control process exited, code=exited, status=1/FAILURE
Feb 15 11:48:06 pi systemd[1]: postgresql.service: Failed with result 'exit-code'.
Feb 15 11:48:06 pi systemd[1]: Failed to start PostgreSQL database server.
[user@pi ~]$ su - postgres -c "initdb --locale en_US.UTF-8 -D '/var/lib/postgres/data'"
su: Authentication failure
[user@pi ~]$ sudo postgres -c "initdb --locale en_US.UTF-8 -D '/var/lib/postgres/data'"
"root" execution of the PostgreSQL server is not permitted.
The server must be started under an unprivileged user ID to prevent
possible system security compromise.  See the documentation for
more information on how to properly start the server.

Before that, the only thing I did is run this: sudo pacman -S nodejs-lts-fermium yarn ffmpeg postgresql openssl redis git wget unzip python base-devel npm nginx which gave me this sudo error:

sudo: error in /etc/sudo.conf, line 0 while loading plugin "sudoers_policy"
sudo: unable to load /usr/lib/sudo/ cannot open shared object file: No such file or directory
sudo: fatal error, unable to load plugins

and I fixed it with this solution:

su - 
pacman-mirrors -g && pacman -Syyu

So the issue was a partial update. Eg. you installed something, without also updating.

Yes that was the error. But I already solved it. I’m asking for another error now, I don’t know if they are related.

Did you read the Arch Wiki page? PostgreSQL - ArchWiki (

It is very important that you run the initdb command as user postgres before you start the service.

1 Like

Thanks, the error message was misleading, it was telling me to use su - instead of the postgres user.

I think I may need to use the database from the default user. What can I do to allow that?

Set up it up and configure it, create a database user and connect to it over network or socket. Check out the ArchWiki how to run and use PostgreSQL. PostgreSQL is not considered to be simple.

Do not run a database like PostgreSQL,MariaDB,MySQL,SQL Server as your normal system user. You might want to read up on how to run this kind of Database.

That’s the error I’m having, I can’t execute the command

su - postgres -c "initdb --locale en_US.UTF-8 -D '/var/lib/postgres/data'"
su: Authentication failure

Since the postgres system user is created automatically, did you set up a password for this user? Otherwise switch to the root user ( su - ) and run the your command again.

This topic was automatically closed 2 days after the last reply. New replies are no longer allowed.