Sunday, January 19, 2014

How to install PostgreSQL 9.2 on Ubuntu 13.04


Installation

The default repository of Ubuntu 13.04 is now not supporting PostgreSQL 9.2 and I got lot of help request, so following is the solution.

To install use the command line and type:

sudo nano /etc/apt/sources.list.d/pgdg.list

Then add the following line.

deb http://apt.postgresql.org/pub/repos/apt/ precise-pgdg main

Press Ctrl X the y to save and exit.

This will add the PostgreSQL repo for Ubuntu 12.04 into Ubuntu 13.04.

Now Add PGP key by executing:

wget --quiet -O - http://apt.postgresql.org/pub/repos/apt/ACCC4CF8.asc | sudo apt-key add –

Then run the following apt commands:

sudo apt-get update

sudo apt-get install postgresql-common -t raring

sudo apt-get install postgresql-9.2

Administration
PGAdmin III is a handy GUI for PostgreSQL, it is essential to beginners. But this will not run on server (i.e. Ubuntu Server 13.04 but can run on Ubuntu desktop 13.04). To install it, type at the command line:

sudo apt-get install pgadmin3

You may also use the Synaptic package manager from the System>Administration menu to install these packages.

Basic Server Setup

To start off, we need to change the PostgreSQL postgres user password; we will not be able to access the server otherwise. As the “postgres” Linux user, we will execute the psql command.

In a terminal, type:

sudo -u postgres psql postgres

Set a password for the "postgres" database role using the command:

\password postgres

and give your password when prompted. The password text will be hidden from the console for security purposes.

Type Control+D to exit the posgreSQL prompt.

Create database

To create the first database, which we will call "mydb", simply type:

 sudo -u postgres createdb mydb

No comments:

Post a Comment