Connect To Postgres from command line in Windows

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.

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.

You may also want to read below articles;

How To Connect To Database On PostgreSQL,

How To Create a Linked Server To Connect To PostgreSQL From SQL Server,

How To Find PostgreSQL lib and bin Directories,

How To Stop, Start, Restart and Reload PostgreSQL Service

Also you can find many article about Postgresql from below link.

https://dbtut.com/index.php/category/postgres/

If you want to read more about psql, open the below link.

https://www.postgresql.org/docs/current/app-psql.html

Faruk Erdem
Author: Faruk Erdem

Leave a Reply

Your email address will not be published. Required fields are marked *