I had installed PostgreSQL but when I do run command postgres
in windows CMD
It gives following error:
postgres does not know where to find the server configuration file.
You must specify the --config-file or -D invocation option or set the PGDATA environment variable.
Even after running command
initdb postgres
as maintained similar Issue
postgres -D C:\Program Files\PostgreSQL\data\
gave me following output:2016-09-28 15:04:57 PDT LOG: could not bind IPv6 socket: Only one usage of each socket address (protocol/network address/port) is normally permitted.
2016-09-28 15:04:57 PDT HINT: Is another postmaster already running on port 5432? If not, wait a few seconds and retry.
2016-09-28 15:04:57 PDT LOG: could not bind IPv4 socket: Only one usage of each socket address (protocol/network address/port) is normally permitted.
2016-09-28 15:04:57 PDT HINT: Is another postmaster already running on port 5432? If not, wait a few seconds and retry.
2016-09-28 15:04:57 PDT WARNING: could not create listen socket for "*"
2016-09-28 15:04:57 PDT FATAL: could not create any TCP/IP sockets
2016-09-28 15:04:57 PDT LOG: database system is shut down
As the error says, to start a postgresql cluster you must set the path to the data folder. Probably something like:
postgres -D "C:\Program Files\PostgreSQL\data\"
but the use of pg_ctl
instead postgres
is recommended:
pg_ctl -D "C:\Program Files\PostgreSQL\data\" start
Don't forget to check the postgres documentation about how to start a server and how to use pg_ctl.
Usually, the postgres installlers creates a service/daemon so there is not need to launch the server by hand. So if you get an error like
Is another postmaster already running on port 5432?
It probably means that the server is already running. Try to connect to it using psql
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With