Installing PostgreSQL client tools on Windows
When we develop applications, we end up hosting them with the desired cloud providers under specific monthly or annual subscriptions. Depending on your plan, these subscriptions provide us with different services like data stored in databases, bandwidth, email services, etc.
There are several ways to access a remote database from your local computer, one of which is through a graphical user interface client or a command line interface based on TCP.
This tutorial will teach you how to install only the PostgreSQL client tools needed to access a remote database on a Windows machine.
Download the full PostgreSQL binary to install the PostgreSQL client tools
This is the first method we can use to install the PostgreSQL client tools.
We must first install the Microsoft Visual C++ Redistributable for this method to work.
Download a zip archive of complete PostgreSQL binaries for Windows operating systems.
Please note that these binaries are provided as a convenience for expert users, and users should use the installer unless they need these files.
Go to the folder where you saved the PostgreSQL binaries Downloads
and unpack the archive.
pgsql
A folder
named was extracted from the archive and it had the folders shown in the image below.
Delete the selected folders as shown above as they are not required to access the remote database.
The remaining folder is the required bin
folder for this method. Go into bin
the folder and copy the path to its location as shown below.
The next step is to add this path to 系统环境变量
so that we can execute PostgreSQL commands.
Click the Windows logo key, search Environment
, and then Edit the system environment variables
click Enterthe key when it returns to Options.
This will return 系统属性
the window as shown below.
Click on 环境变量
the window, another window will open 用户变量
and 系统变量
. Select 路径
the option and click on 编辑
the button.
In the new window that opens, press new
the button and paste the location of the PostgreSQL folder that we copied bin
into the blank field as shown below.
The last step is to verify that we can execute PostgreSQL commands from the terminal. In this example, we will not connect to any remote database, but if you have one, use the following command to access your database.
>psql -h <host> -d <database> -U <username> -p <port> -W
Open the Windows Command Prompt to verify that our configuration is working properly, type psql
and press on your keyboard Enter. As shown below, the command tries to connect to the local PostgreSQL server, but since we don’t have any PostgreSQL server installed, it doesn’t work.
Install PostgreSQL client tools using the PostgreSQL installer
Download the PostgreSQL installer for Windows and run the software.
The software has several products that can be installed as shown below, but since we are only interested in the command line tools, deselect all the others and click on 下一步
.
After the installation is complete, copy the folder location installed under Program Files
>> as shown below.PostgreSQL
14
bin
The next step is to install and add the location to 系统变量
. The steps we covered above are similar to this method; so there is no need to repeat them.
Make sure to remove the PostgreSQL environment variables we added earlier. After adding the new environment variables under Location >> > Program Files
, PostgreSQL
open the Windows Command Prompt and test the configuration again using the command.14
bin
psql
The command tries to connect to the local PostgreSQL server but is unsuccessful because we don’t have any database server installed, as we saw in the previous method.
For reprinting, please send an email to 1244347461@qq.com for approval. After obtaining the author's consent, kindly include the source as a link.
Related Articles
Terminate the PostgreSQL connection
Publish Date:2025/04/11 Views:199 Category:PostgreSQL
-
In this article, we will learn how to terminate a PostgreSQL session. Any open connections are run by background processes or tasks, PSQL which may no longer exist despite exiting the user interface or command line tool. Use ps -ef or grep
Single query to rename and change column type in PostgreSQL
Publish Date:2025/04/11 Views:166 Category:PostgreSQL
-
This article describes how to rename a column and change its type in PostgreSQL using only a single query. Renaming and changing column types in MySQL In MySQL , if you want to change the column type and rename it, you can use a simple stat
Joining columns using Select in PostgreSQL
Publish Date:2025/04/11 Views:176 Category:PostgreSQL
-
MySQL PostgreSQL is an object-relational database system, which means it can support more complex data types than its competitors . Today we will learn how to use SELECT the operator to join the columns of a table. Using operators to || joi
Using CASE in PostgreSQL
Publish Date:2025/04/11 Views:124 Category:PostgreSQL
-
This article shows how to use the statement in PostgreSQL CASE . CASE How to use the statement in PostgreSQL case Statements are similar to those in general-purpose programming languages if-else . But in SQL, if you want to write IF-ELSE ,
Using NOT IN with subqueries in PostgreSQL
Publish Date:2025/04/11 Views:93 Category:PostgreSQL
-
NOT IN The inverts the result of NOT simply using IN the operator. NOT IN The right side of the operator must have a subquery in which multiple columns are returned to check whether the expression matches the data. NOT IN Tends to return tr
Using variables in PostgreSQL
Publish Date:2025/04/11 Views:171 Category:PostgreSQL
-
This article will demonstrate how we can declare and assign values to variables in PostgreSQL. In PostgreSQL, DECLARE variables are declared using Often you will need variables in your PL/SQL scripts. In DECLARE the section called , y
Connect to PostgreSQL using a password
Publish Date:2025/04/11 Views:171 Category:PostgreSQL
-
This article shows various ways to connect to PostgreSQL using a password. It can be through the command line, pgpass a file, PGPASSWORD an environment variable or a connection string. Connecting to PostgreSQL with a password using the comm
Deleting a database in PostgreSQL via PSQL
Publish Date:2025/04/11 Views:166 Category:PostgreSQL
-
There are two ways to access PostgreSQL objects and databases on your system. One is through an interface, such as a graphical interface like PGADMIN, and the other is the basic command line tool psql. Today, we will look at DROP DATABASE t
Using the database in PostgreSQL
Publish Date:2025/04/11 Views:132 Category:PostgreSQL
-
This article demonstrates connecting to a database, creating a new database, and creating a table in PostgreSQL. Available databases in PostgreSQL You can run the following command after opening the Postgres command line to view all availab