---
title: "postgresql install and configure for ubuntu"
author: "夜鸣猪"
date: "2013-04-25T08:13:01Z"
tags: []
categories: ["编程语言"]
slug: "postgresql-install-and-configure-for-ubuntu"
draft: false
lastmod: "2013-05-09T11:21:40Z"
id: 1853237
url: "https://hlee.iteye.com/blog/1853237"
---

### ABSTRACT

PostgreSQL is an object-relational database system that has the features of traditional commercial database systems with enhancements to be found in next-generation DBMS systems. This blog entry documents the installation process of the PostgreSQL database on Ubuntu Linux.

 

 

```
sudo apt-get install postgresql
sudo apt-get install libpq-dev
```

### INTRODUCTION

I have selected [PostgreSQL 9.1](http://www.postgresql.org/download/linux/ubuntu) and [Ubuntu Linux 12.10 32 bit](http://cdimage.ubuntu.com/releases/12.10/release). The installation process follows the `apt-get install configure` pattern.

### STEP 1: VERIFY THAT YOU DO NOT ALREADY HAVE POSTGRESQL INSTALLED ON YOUR SYSTEM

Run the following command in your console:

1

`ps` `ax | grep` `postgres`

If you get a response similar to the one below, then you have PostgreSQL installed.

1

2

3

4

`Ss 0:00 postgres: writer process`

`Ss 0:00 postgres: wal writer process`

`Ss 0:00 postgres: autovacuum launcher process`

`Ss 0:00 postgres: stats collector process`

### STEP 2: INSTALL POSTGRESQL ON YOUR SYSTEM

Run the following commands in your console:

1

2

`sudo` `apt-get update`

`sudo` `apt-get install` `postgresql-9.1`

### STEP 3: CONFIGURE YOUR POSTGRESQL PASSWORD

1

2

3

`sudo` `-u postgres psql template1`

`ALTER USER postgres with encrypted password 'your_password';`

`Press ctrl-d`

### STEP 4: CONFIGURE MD5 AUTHENTICATION

1

`sudo` `nano /etc/postgresql/9.1/main/pg_hba.conf`

Update the

1

`local` `all postgres`

entry to

1

`local` `all postgres md5`

### STEP 5: ENABLE TCP/IP CONNECTIONS

1

`sudo` `nano /etc/postgresql/9.1/main/postgresql.conf`

Locate the line

1

`#listen_addresses = 'localhost'`

and change it to:

1

`listen_addresses = 'localhost'`

*To allow other computers to connect to your PostgreSQL server replace ‘localhost’ with the IP Address of your server, or alternatively to ’0.0.0.0′ to bind to all interfaces.*

### STEP 6: RESTART POSTGRES

1

`sudo` `service postgresql restart`

### STEP 7: CONGRATULATIONS! YOU HAVE SUCCESSIVELY INSTALLED POSTGRESQL ON UBUNTU