RDBMS-PostgreSQL/C2/Installation-of-PostgreSQL/English

From Script | Spoken-Tutorial
Jump to: navigation, search

>>Title of script: Installation of PostgreSQL

Author: Nirmala Venkat

Keywords: RDBMS, PostgreSQL, PgAdmin, Installation on Linux, Installation on windows, video tutorial

Visual Cue Narration
Slide 1: Welcome to the Spoken Tutorial on Installation of PostgreSQL.
Slide 2a:

Learning Objectives

In this tutorial we will learn to install PostgreSQL on
  • Ubuntu Linux OS and
  • Windows operating system
Slide 2b:

Learning Objectives

We will also learn to
  • Connect to PostgreSQL database and
  • Set password for the database
Slide 3:

System requirement

To record this tutorial, I am using
  • Ubuntu Linux 14.04 operating system and
  • Windows 7 operating system and
  • a working Internet connection
Slide 4:

Pre-requisites

To follow this tutorial, you should
  • be familiar with either of the mentioned operating system
  • and have working knowledge of any programming language.
Slide 5:

What is PostgreSQL?

  • PostgreSQL is a relational database management software.
  • It is a powerful and most advanced open source database system.
  • It runs on various platforms such as Linux, Windows and Mac OS.
First we will see how to install PostgreSQL on Linux.
Press CTRL + Alt + T Press CTRL + ALT +T keys simultaneously to open the terminal.
In the terminal window, type

>sudo apt-get update

Press Enter.

In the terminal window, type

sudo apt hyphen get update and press Enter.

Enter the administrative password if prompted.

This command will update the Ubuntu's default repositories.

Wait until it finishes all the updates.

Press Ctrl L to clear the screen.
> sudo apt-get install postgresql

Press Enter.

Next, type

sudo apt hyphen get install postgresql

and press Enter.

Point to the installation process

Enter 'Y'

We can see the installation process has begun.

Press 'Y' wherever there is a prompt to confirm the configuration.

Installation will take sometime to complete, depending upon your Internet speed.

Point to the prompt Now we can see that the installation has been completed successfully.

Press Ctrl + L to clear the screen.

By default, a user account called postgres is created during installation.

But there is no password set for this user account.

Type

sudo -u postgres psql postgres

To set the password, type

sudo hyphen u postgres psql postgres and press Enter.

Enter the system password

Point to the change in the prompt

Enter your system password if prompted.

Notice that the prompt has changed to postgres equal to hash.

Type \password postgres. At the prompt, type slash password postgres.
Type the password Immediately you will be prompted to set a new password for the Postgres user.

I'll enter the password as 'postgres'.

You can enter a password of your choice.

Re-type the password Enter the same password one more time.
Please remember this password for future use.
Type,

Postgres=#> select version();

Next type,

select version open bracket close bracket semicolon and press Enter.

Do not forget to put the semicolon at the end of each statement.

Highlight the Version The PostgreSQL version that we have installed now, is displayed on the terminal.

This indicates that we have successfully installed PostgreSQL.

Hit 'q' Key to exit I have increased the terminal font size for this demo.

Hence the output is seen in a different window.

So I’ll hit the ‘q’ key to exit.

You may not require to do so.

Now let us see how to disconnect from the server.
Type \q' and press Enter Type slash q and press Enter to disconnect from the server.

Notice that we are back at the command prompt of the terminal.

Every time when you want to work with PostgreSQL, you need to be connected to the server.
Slide 6:

Connect to PostgreSQL database using psql

  • Psql is an interactive terminal program provided by PostgreSQL.
  • We can execute SQL statements, manage database objects etc.
Psql is an interactive terminal program provided by PostgreSQL.

Using psql tool, we can execute SQL statements, manage database objects etc.,

Slide 7:

Connect to PostgreSQL database using pgAdmin

  • pgAdmin is a GUI application.
  • Interact with PostgreSQL database server through this user interface.
  • Demonstration of all features using pgAdmin in this series.
Another way to connect to a database is using pgAdmin GUI application.

We can interact with PostgreSQL database server through this interface.

We will be demonstrating all features using pgAdmin in this series.

Switch back to terminal.

Let us again connect to the postgreSQL database from the command line.

Type psql -U postgres -h localhost -W and press Enter. For this, type

sudo psql hyphen capital U postgres hyphen h localhost hyphen capital W

and press Enter to connect to the server.

hyphen h is the hostname or IP of the local server.

Enter the password for postgres user. Enter the password for postgres user which you have set after installation.
Prompt changes to Postgres=# We can see the prompt changes to Postgres.

Press Ctrl + L to clear the screen.

Let us verify the PostgreSQL database and whether the server has been started by a simple query.
Type,

Select current_user, now();

Highlight the output

Type,

Select current underscore user, now();

We can see the user name and current date as output.

Hit ‘q’ to exit.

During installation, some sample databases are created automatically.

Let us have a look at them.

Type slash list or slash l and press Enter. Type slash list or slash l and press Enter.
Highlight the available databases We can see the below database names that are available in PostgreSQL server by default.
Type \c postgres;

Point to the message

To change a database, type slash c database name.

I will type ' slash c postgres;'

Then type the postgres password.

We can see a message saying ' You are now connected to database “postgres” as user “postgres”

We can create our own database and tables as per our requirement.

All the database commands can be executed from the command line.

Type \q Type 'slash q' to disconnect from the server.
Now let us see how to install PgAdmin.
Slide 8:

Install using anyone of the following methods

  1. Go to Ubuntu Software Centre or Synaptic Package manager
  1. For more details, refer to the Linux spoken tutorials on our website.

http://spoken-tutorials.org

  1. Type on the terminal

sudo apt-get install pgadmin3

PgAdmin can be installed by using any one of the following methods on Ubuntu Linux OS.

Go to Ubuntu Software Centre or Synaptic Package manager, search for PgAdmin and install.

For more details, refer to the ‘Linuxspoken tutorials on our website.

Or in the Terminal, type -

sudo apt hyphen get install pgadmin3 and press Enter

I have already installed PgAdmin in my machine.

I'll show how to open PgAdmin.

Click Dash home Click Dash Home on the top left corner of the desktop.
In the search box type, Pgadmin In the Search box, type PgAdmin.

The PgAdmin icon appears. Click on it.

Point to the interface The PgAdmin interface opens.
Now let us learn to install PostgreSQL on Windows OS.
In the web browser, type

https://www.postgresql.org/download

Click on the windows link.

Open your web browser and go to https://www.postgresql.org/download

Click on the Windows link.

Click on the Download the graphical installer Then, click on the Download the graphical installer link.
Point to the latest version

Click on the Previous supported versions

I have installed postgres version 9.3.x in Linux OS.

Now I would like to install the same version in Windows also.

You can also install the latest stable version.

So click on the Previous supported versions and look for version 9.3.x

Click the link near the windows icon. Click the link near to the Windows icon.
Point to the dialog box It will open a dialog box to save the file.
Click on the Save File button Click on the Save File button.
It will take sometime to download the file. Wait until it is finished.
Point to the Downloads folder I have already downloaded it in my machine in the Downloads folder.
Go to the Downloads folder and double click on the downloaded file. Go to the Downloads folder and double-click on the downloaded file. It will open a window.
Click on the Run button. Click on the Run button.
Click on the Next button. In the setup window, click on the Next button.
Click on the Next button. Select the components and click on the Next button.
Click on the Next button. In the Installation directory, click on the Next button.
Enter the password Enter the password for postgres and re-type one more time. Click on the Next button.
Installation has started. Wait until it finishes completely.
Click Finish Next click on the Finish button to complete the installation.
Click Exit Lastly, exit from the wizard.
Let us see how to open the PostgreSQL command line on Windows.
Click on Start>> All program>>PostgreSQL 9.3 >>SQL Shell Click on Start, then All program then PostgreSQL and psql to open the command line.

We can see the postgres=# prompt.

Postgres=# select version(); Type select version() semicolon and press Enter to see the installed version of postgresql.

This indicates that we have successfully installed in Windows.

Close the window Close the window.
Let us open the PgAdmin from Windows.
Click on Start, then All program then PostgreSQL 9.3 >>PgAdmin Click on Start, then All program then PostgreSQL and PgAdmin3 to open the GUI interface.
With this, we come to the end of this tutorial. Let us summarize.
Summary In this tutorial, we have learnt to install PostgreSQL on
  • Ubuntu Linux and
  • Windows operating systems.
Assignment As an assignment,
  1. Connect to the server and list the default available database
  2. Change to anyone of the available database
Slide 12:

About Spoken Tutorial project

The video at the following link summarises the Spoken Tutorial project.

Please download and watch it.

Slide 13:

Spoken Tutorial workshops

The Spoken Tutorial Project Team

The Spoken Tutorial Project Team
  • conducts workshops using spoken tutorials and
  • gives certificates on passing online tests.

For more details, please write to us.

Slide 15:

Forum for specific questions:

  • Do you have questions in THIS Spoken Tutorial?
  • Please visit this site
  • Choose the minute and second where you have the question
  • Explain your question briefly
  • Someone from our team will answer them
Slide 16

Forum for specific questions:

  • The Spoken Tutorial forum is for specific questions on this tutorial
  • Please do not post unrelated and general questions on them
  • This will help reduce the clutter
  • With less clutter, we can use these discussion as instructional material
Slide 14:

Acknowledgement

Spoken Tutorial project is funded by NMEICT, MHRD, Government of India.

More information on this mission is available at

this link.

This is Nirmala Venkat from IIT Bombay, signing off. Thanks for watching.

Contributors and Content Editors

Nancyvarkey, Nirmala Venkat, PoojaMoolya