0% found this document useful (0 votes)
0 views13 pages

Installation of PostgreSQL On Windows and Ubuntu

This document outlines the installation process of PostgreSQL on Windows and Ubuntu. For Windows, it details steps including downloading the installer, configuring installation options, and verifying the installation using pgAdmin or psql. For Ubuntu, it provides commands to set up the PostgreSQL repository, install PostgreSQL, change the default user password, and install pgAdmin for database management.

Uploaded by

abhijithrajvp5
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
0 views13 pages

Installation of PostgreSQL On Windows and Ubuntu

This document outlines the installation process of PostgreSQL on Windows and Ubuntu. For Windows, it details steps including downloading the installer, configuring installation options, and verifying the installation using pgAdmin or psql. For Ubuntu, it provides commands to set up the PostgreSQL repository, install PostgreSQL, change the default user password, and install pgAdmin for database management.

Uploaded by

abhijithrajvp5
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 13

Install PostgreSQL on Windows and Ubuntu

Installation process of PostgreSQL

This document discusses detail installation process of PostgreSQL on Windows and Ubuntu.

Install PostgreSQL on Windows


There are three steps to complete the PostgreSQL installation:

1. Download PostgreSQL installer for Windows


2. Install PostgreSQL
3. Verify the installation

1) Download PostgreSQL Installer for Windows


First, you need to go to the download page of PostgreSQL installers on the EnterpriseDB.

Second, click the download link as shown below:

It will take a few minutes to complete the download.

2) Install PostgreSQL on Windows step by step


To install PostgreSQL on Windows, you need to have administrator privileges.
Step 1. Double click on the installer file, an installation wizard will appear and guide you
through multiple steps where you can choose different options that you would like to have in
PostgreSQL.

Step 2. Click the Next button

Step 3. Specify installation folder, choose your own or keep the default folder suggested by
PostgreSQL installer and click the Next button

Step 4. Select software components to install:

• The PostgreSQL Server to install the PostgreSQL database server


• pgAdmin 4 to install the PostgreSQL database GUI management tool.
• Command Line Tools to install command-line tools such as psql, pg_restore, etc. These
tools allow you to interact with the PostgreSQL database server using the command-line
interface.
• Stack Builder provides a GUI that allows you to download and install drivers that work
with PostgreSQL.

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 6. Enter the password for the database superuser (postgres)


PostgreSQL runs as a service in the background under a service account named postgres. If you
already created a service account with the name postgres, you need to provide the password of
that account in the following window.
After entering the password, you need to retype it to confirm and click the Next button:

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:

First, launch the pgAdmin 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:

Install PostgreSQL on Ubuntu


Once visiting the PostgreSQL download for Ubuntu page, you find the script that allows you to
install PostgreSQL on Ubuntu. You need to execute them one by one. Start terminal window in
your Ubuntu system and execute the following command:

First, execute the following command to create the file repository configuration:

$ sudo sh -c 'echo "deb http://apt.postgresql.org/pub/repos/apt


$(lsb_release -cs)-pgdg main" >
/etc/apt/sources.list.d/pgdg.list'
Second, import the repository signing key:

$ wget --quiet -O -
https://www.postgresql.org/media/keys/ACCC4CF8.asc | sudo apt-
key add -
Third, update the package list:

$ sudo apt-get update


Finally, install the latest version of PostgreSQL:

sudo apt-get install postgresql


It will ask for administrative password and then proceed with the installation. The installation
process is not much interactive. Only once it asks you "Do you want to continue?". Press Y and
installation will continue. As soon as the installation is finished, it will take you to the command
prompt again. The installation process also installs PostgreSQL client.

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:

$ sudo apt-get install postgresql-12


It will take few minutes to download and install the PostgreSQL.

The following pictorial is taken while installing PostgreSQL in Ubuntu.

Change the PostgreSQL postgres user password

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.

sudo -u postgres psql postgres

The following pictorial is taken after we ran the above command.


Now run the following command to be prompted to supply a password for "postgres" database
role.

\password postgres

The following pictorial is taken after we ran the above command.

'>

To exit the PostgreSQL command prompt, type Contrl+D.

Install pgAdmin - GUI to manage PostgreSQL

Refer: https://www.pgadmin.org/download/pgadmin-4-apt/

Run the following command to install pgadmin4.

sudo apt-get install pgadmin4

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.

You might also like