Install PostgreSQL on Linux and Windows

Installation process of PostgreSQL

This document discusses detail installation process of PostgreSQL on Linux and Windows. For demonstration purpose, we have used Ubuntu Linux and Windows 7.

Install PostgreSQL on Linux

We are installing PostgreSQL on Ubuntu Linux. Make sure that you have an internet connection enabled and you have administrative privileges.

Start terminal window in your Ubuntu system and execute the following command :

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. The following pictorial is taken while installing PostgreSQL in Ubuntu.

install postgresql 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.

postgresq commandline ubuntu

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.

postgresql change password ubuntu'>

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

Install pgAdmin III - GUI to manage PostgreSQL

Run the following command to install pgadmin3.

sudo apt-get install pgadmin3

The installation process starts and after asking once "Do you want to continue?" it continues. Press y when it asks so. The following pictorial is taken while running the above command.

install pgadmin3 ubuntu

You can start pgadmin III from Application > Programming > pgadmin III.

pgadmin3 ubuntu

We will use this tool often to manage PostgreSQL in the upcoming tutorials. That is all for now about how to install PostgreSQL and pgadmin3 in Ubuntu. If you have any queries and or suggestions, please use our comment section. We will now move to the next section of this document and see, how to install PostgreSQL and pgadmin III in Windows 7.

Install PostgreSQL on Windows

Download PostgreSQL

To download PostgreSQL to install it on Windows 7, please visit the following web page : http://www.postgresql.org/download/windows and click on the "Download" link under "One click installer". The downloaded package will install PostgreSQL Server and pgadmin III GUI to manage PostgreSQL Server and StackBuilder which can be used to download drivers and tools for PostgreSQL Server.

Once you click on the said "Download" link, it will take you to another page from where you need to select the package depending upon your OS platform. So, for installing PostgreSQL on 32 bit Windows 7, select "Win x86-32". If you are using a 64 bit OS, select "Win x86-64". That will start the download process and depending up on your connection speed, take a while to get downloaded.

Make sure you have turned Third Party AntiVirus off while installing.

Once the download is finished, run the postgresql-9.1.1-1-windows.exe file and select the location where you want to install it. By default, it is installed within Program Files folder. Then it asks you to enter a password. Keep the port as default. When asked for "Locale", we have selected "English, United States". It will take a while to install PostgreSQL on your system.

install postgresql windows7

On completion of the installation process, you will get the following screen.

installation postgresql windows7 complete

After the installation process is completed, you can access pgAdmin III, psql, StackBuilder and PostgreSQL shell from your Program Menu under PostgreSQL 9.1.

That's all for now as far as installation of PostgreSQL Server on Windows 7 is concerned. Please use our comment section down this document if you have any queries or suggestions.

Previous: PostgreSQL Home
Next: Connect to PostgreSQL

Follow us on Facebook and Twitter for latest update.