Unable to start posgtresql, the reason isn't clear
93,299
Solution 1
Following step solved your problem
step 1: create the data directory (acordingly with the PGROOT variable set before in the config file)
sudo mkdir /var/lib/postgres/data
Step 2: set /var/lib/postgres/data ownership to user 'postgres'
chown postgres /var/lib/postgres/data
Step 3: As user 'postgres' start the database.
sudo -i -u postgres
initdb -D '/var/lib/postgres/data'
Step 4: Start the service as root
Solution 2
run these commands as said on /usr/share/doc/postgresql/README.rpm-dist
as root user
postgresql-setup --initdb
systemctl restart postgresql.service
systemctl enable postgresql.service
Related videos on Youtube
Author by
Matudi
Updated on September 18, 2022Comments
-
Matudi over 1 year
I've installed postgresql by pacman. Now I'm trying to run it:
$ sudo systemctl start postgresql Job for postgresql.service failed because the control process exited with error code. See "systemctl status postgresql.service" and "journalctl -xe" for details.
And then:
$ sudo systemctl status postgresql ● postgresql.service - PostgreSQL database server Loaded: loaded (/usr/lib/systemd/system/postgresql.service; disabled; vendor preset: disabled) Active: failed (Result: exit-code) since Sun 2016-07-10 15:30:47 UTC; 17s ago Process: 19468 ExecStartPre=/usr/bin/postgresql-check-db-dir ${PGROOT}/data (code=exited, status=1/FAILURE) Jul 10 15:30:47 my_comp systemd[1]: Starting PostgreSQL database server... Jul 10 15:30:47 my_comp systemd[1]: postgresql.service: Control process exited, code=exited status=1 Jul 10 15:30:47 my_comp systemd[1]: Failed to start PostgreSQL database server. Jul 10 15:30:47 my_comp systemd[1]: postgresql.service: Unit entered failed state. Jul 10 15:30:47 my_comp systemd[1]: postgresql.service: Failed with result 'exit-code'.
What's wrong with it?
-
Craig Ringer almost 8 yearsTake a look at PostgreSQL's log files to see. It's a pity that the systemd output doesn't point to them, or that PostgreSQL on this system isn't configured to output its logs to systemd.
-
Jeff Schaller almost 8 yearsdoes this archlinux link get you any closer?
-
Matudi almost 8 years@CraigRinger, it doesn't exist.
-
-
Wedge Martin over 6 yearsDepending on version, this may need to be
initdb -D '/var/lib/pgsql/data'
-
Chalist over 4 yearsIf you had a few databases, this will create fresh Postgresql server without old databases!
-
Akash Pagar almost 4 yearsstep4: how to start the service in root?
-
Akash Pagar almost 4 yearsyes. it worked. by logged in using
sudo -i -u postgres
start service usingpg_ctl -D /var/lib/postgres/data -l logfile start
-
AlxVallejo over 2 yearspostgresql-setup: command not found
-
AlxVallejo over 2 years-bash: initdb: command not found
-
MasterOfNone about 2 yearsThis worked for me in a current and up-to-date RHEL 8.5 server.