Sometimes you may need to connect to postgresql from command line in windows. In this article, I will show you how to do this.
First, psql must be installed on your server. If you installed pgadmin, postgresql on the server you want to connect to, psql was installed with it. In this article, I will assume that you have installed pgadmin.
We open the command line to connect to postgres and run the following command and go to the path where psql.exe is.
c:\Program Files (x86)\pgAdmin 4\v4\runtime>
After going to the path above, we list the files in it with the dir command.
Connect To Postgres Database from command line in Windows
Now we see that we have a psql client, we can connect to postgres db from command line in windows as follows.
psql -h localhost -U postgres
You may also want to read below articles;
Also you can find many article about Postgresql from below link.
If you want to read more about psql, open the below link.