Installation of PostgreSQL On Windows and Ubuntu
Installation of PostgreSQL On Windows and Ubuntu
This document discusses detail installation process of PostgreSQL on Windows and Ubuntu.
Step 3. Specify installation folder, choose your own or keep the default folder suggested by
PostgreSQL installer and click the Next button
•
For the tutorial on this website, you don’t need to install Stack Builder so feel free to uncheck it
and click the Next button to select the data directory:
Step 5. Select the database directory to store the data or accept the default folder. And click the
Next button to go to the next step:
Step 7. Enter a port number on which the PostgreSQL database server will listen. The default
port of PostgreSQL is 5432. You need to make sure that no other applications are using this port.
Step 8. Choose the default locale used by the PostgreSQL database. If you leave it as default
locale, PostgreSQL will use the operating system locale. After that click the Next button.
Step 9. The setup wizard will show the summary information of PostgreSQL. You need to
review it and click the Next button if everything is correct. Otherwise, you need to click the Back
button to change the configuration accordingly.
Now, you’re ready to install PostgreSQL on your computer. Click the Next button to begin
installing PostgreSQL.
The installation may take a few minutes to complete.
Step 10. Click the Finish button to complete the PostgreSQL installation.
3) Verify the Installation
There are several ways to verify the PostgreSQL installation. You can try to connect to the
PostgreSQL database server from any client application e.g., psql and pgAdmin.
a) Through PgAdmin
The pgAdmin application allows you to interact with the PostgreSQL database server via an
intuitive user interface.
The following illustrates how to connect to a database using pgAdmin GUI application:
The pgAdmin application will launch on the web browser as shown in the following picture:
Click on the Servers node to expand the server. By default, PostgreSQL has a database named
postgres as shown below:
Enter the query in the Query Editor, click the Execute button, you will see the result of the query
displaying in the Data Output tab:
b) Through the psql program.
First, click the psql application to launch it. The psql command-line program will display.
Second, enter all the necessary information such as the server, database, port, username, and
password. To accept the default, you can press Enter. Note that you should provide the
password that you entered during installing the PostgreSQL.
Server [localhost]:
Database [postgres]:
Port [5432]:
Username [postgres]:
Password for user postgres:
psql (12.3)
WARNING: Console code page (437) differs from Windows code page (1252)
8-bit characters might not work correctly. See psql reference
page "Notes for Windows users" for details.
Type "help" for help.
postgres=#
Third, issue the command SELECT version(); you will see the following output:
First, execute the following command to create the file repository configuration:
$ wget --quiet -O -
https://www.postgresql.org/media/keys/ACCC4CF8.asc | sudo apt-
key add -
Third, update the package list:
If you want to install a specific version, you can use postgresql-version instead of postgresql. For
example, to install PostgreSQL version 12, you use the following command:
The default user for PostgreSQL is "postgres". The first thing you need to do after you successfully
installed PostgreSQL, is to change the password for the "postgres" user. For doing so, run the
following command, which will take you to the PostgreSQL command line.
\password postgres
'>
Refer: https://www.pgadmin.org/download/pgadmin-4-apt/
The installation process starts and after asking once "Do you want to continue?" it continues. Press
y when it asks so.
You can start pgadmin4 from Application > Programming > pgadmin4.