Do you want to access the remote databases installed on the PostgreSQL server from Windows 11 or 10? But don’t want the complete suite of this Database server. Then there is a way using which we can only get the PostgreSQL client but without PGAdmin and other tools on our local machine. In this tutorial, we learn how you can install PSQL Client on Windows 10 or 11:
1. Download the PostgreSQL Client Installer
We can use the Winget package manager to install the PostgreSQL client on Windows 10/11 but it will install the complete server setup. However, here in this tutorial we only want the PSQL client and other important command line tools of it. Therefore, first manually download the PostgreSQL installer package from the EnterpriseDB. Use the link and get the Windows x86-64 Installer.
2. Choose Your Installation Folder
Once the Installer setup is downloaded successfully, double-click to start it. The system will give a warning, ignore it and just click on the RUN button.
After that click on the NEXT from the installation wizard. Now, it will ask for the Installation folder, by default it will be at C:\Program Files\PostgreSQL\”version”.
If you want to change because your C drive doesn’t have enough space or due to any other reason then click on the folder icon and select the directory you want to set.
However, it is recommended to let the default folder be selected if you are not sure about it and simply click on the Next button.
3. Select Command Line Tools to install the PSQL client
By default, the installer will have all the PostgreSQL components selected such as Server, pgAdmin 4, Stack builder, and Command Line Tools. However, we don’t want the server and other components instead only the PSQL client.
So, uncheck other options and let the CL tools only be selected. This will also install other necessary CLI tools such as pg_dump, pg_restore, pg_bench, pg_basebackup, and more. Now, move forward using the Next button and finish the installation process.
4. Run PSQL Client Shell on Windows 11 or 10
Click on the Windows Start button and type
psql in the search box. Soon you will see SQL Shell (psql) client app option. Select it to run.
5. Connect your remote PostgreSQL server Database
- Once you are on the PSQL client Shell you will see, it will ask you for the Server address. As we don’t have a Database server installed locally, therefore, enter the IP address or domain name of your remote PostgreSQL server.
- After that, enter the name of the Database you want to connect.
- By default, the port to access the PostgreSQL server is 5432, if you haven’t changed it then simply press the Enter key to go by the default one.
- Now, provide the username that is associated with the Database you want to access.
- If everything is correct, the PSQL client will establish a successful connection with the PostgreSQL server and will ask you for the password set for the User of the Database. Provide that and hit the Enter key.
- You will have the shell of the Database to execute SQL commands.