PostgreSQL Installation Guide on Ubuntu

Source: Internet
Author: User
Tags postgresql psql postgres database

Original address: http://www.cnblogs.com/bluesfeng/archive/2010/09/01/1815417.html

Installation Environment:

Ubuntu 10.04-desktop-i386

PostgreSQL 8.4

1. Installing PostgreSQL

Enter the following command

sudo apt-get install PostgreSQL

You will be prompted to install the required disk space, enter "Y" and the Setup program will complete automatically. After installation, the system creates a database Superuser "Postgres" with a blank password. This user is both a non-logged operating system user and a database user.

2. Modify the password for Linux user Postgres

Enter the following command

sudo passwd postgres

3. Modify the password of the database super user Postgres

1) switch to Linux under Postgres user

sudo su postgres

2) Log in to the Postgres database

Psql Postgres

This way you will see the Postgres prompt message as follows:

Psql (8.4.4)

Type ' help ' for help.

and the command line prompt symbol for Postgres appears:

postgres=#

3) Enter the following command

ALTER USER postgres with PASSWORD ' PASSWORD '

Type "Exit" to return to the Linux command line. Note: Here is the type (type) \p return linux command

4. Add your own defined users and databases

1) Add New user

CREATEUSER-DRSP Fedoraadmin

Follow the prompts to enter the user's password.

2) Create a database that belongs to the custom user Fedoraadmin

Createdb-o Fedoraadmin MyDB

The Postgressql database can be connected in Java through the following configuration, as set up above

User:fedoraadmin

Password:your Password

Url:jdbc:postgresql://localhost:5432/mydb

5. Installing pgAdmin3

1) Type the following command to install PgAdmin3

sudo apt-get install pgadmin3

2) Type the following command to run PgAdmin3

Pgadmin3

You will see that the main interface of PgAdmin3 is as follows:

Add the appropriate parameters to create a connection to PostgreSQL:

Note: If you throw an exception at the link below, leave servicel blank and try

6. Setting up access to postgres on other machines

Modify/etc/postgresql/8.4/main/pg_hba.conf:

Host all 0.0.0.0/0 MD5 #0.0.0.0 is the address segment, and 0 is the number of bits

For example: 192.168.0.0/16 represents 192.168.0.1-192.168.255.254

Modify/etc/postgresql/8.4/main/postgresql.conf

listen_address = ' * '

Restart database

sudo/etc/init.d/postgresql-8.4 restart

PostgreSQL Installation Guide on Ubuntu

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.