'Postgres - command not found
I'm trying to setup a working test DB with postgreSQL 13 by following a tutorial but I'm completely confused about which command really exists and which does not...
To start my server, the tutorial tells me to run the following command:
postgres -k "$PGHOST"
It says it should start the server and put the connection socket in the right place but this command does not exists on my system. I installed PosgreSQL from the official repository (Linux Mint 20).
I searched for this command on the web but the result are confused. Some peoples uses this command, some others uses pg_ctl (which does not exists either).
My question is the following: How to start a simple PostgreSQL Server and specify the place to put the socket ?
Solution 1:[1]
I finally found the trick: The folder containing the postgres executable (as well as initdb and some other stuff) is not in the PATH by default.
If anyone has the same problem: it is located in /usr/lib/postgresql/13/bin/
for me.
Solution 2:[2]
Just to add some clarity to this question and for future readers, as I have found this command doesn't work unless you explicitly call the exact path of the binaries folder. For me the the path was
/usr/lib/postgresql/12/bin/initdb
Note the 12 before the bin folder. 12 is the version i am running, so yours might be different depending on your installed version. You can pull up your installed version on Linux with
psql --version
Executing the initdb command on the right path fixes the problem. Eg. :
/usr/lib/postgresql/12/bin/ -D mydatabasename
I also checked if the link was already existing by executing :
ln -s /usr/lib/postgresql/12/bin/psql /usr/bin/psql
The above command will simply fail if the link exists, and I was sure it did.
Something worth noting here is that the link exists already, but the link is not the link where the initdb scripts reside. So executing initdb commands won't work because your link is pointing to the wrong path. The binaries are actually in the following folder
/usr/lib/postgresql/12/bin/
and not the link path provided by the postgresql installer.
Is this a bug? I don't actually know. But this is what worked for me.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|---|
Solution 1 | JM445 |
Solution 2 | Keith Sheepings |