Install Postgresql, phpPgAdmin and pgadmin on Ubuntu

Install

Postgresql , phpPGAdmin and pgadmin 3 can be installed from synaptic.

$ sudo apt-get install postgresql phppgadmin pgadmin3

After installation some configuration needs to be done. First of all setup the password of the user 'postgres'
which is the default user of postgresql.

Type the following in the terminal

$ sudo -u postgres psql

This will start the postgresql shell/console. Now to change the password type 'password postgres;'

$ sudo -u postgres psql
psql (9.1.5)
Type "help" for help.

postgres=# 
postgres=# 
postgres=# password postgres;
Enter new password: 
Enter it again: 
postgres=#

Now psql will ask for a new password twice. Enter the new password and continue. Type 'q' and hit enter to quit.

After installation the postgres password of postgresql can be changed like this :

To create a database the following command can be run from the terminal

$ sudo -u postgres createdb mydb

Pgadmin

Pgadmin is a gui tool to administer and manage postgresql databases etc. To run pgadmin check the gnome/kde menu or just run pgadmin3 from terminal.

Go to File > Add Server and fill in the details
Name : Anything
Host : 127.0.0.1
Username : postgres
Password : Whatever you entered in the previous step.

After clicking OK it should connect and there should be an option on the left window pane to manage the databases.

Phppgadmin

After installing phppgadmin there should be symlink /var/www/phppgadmin which would point to /usr/share/phppgadmin
If the symlink does not exist then it can be created by issuing the following command

$ ln -s /usr/share/phppgadmin /var/www/phppgadmin

Now open the url "localhost/phppgadmin" in your browser. If it shows Forbidden then try to change the permissions of the directory /usr/share/phppgadmin. If that does not work then create a separate symlink, e.g. /var/www/postgres and use that.

Trying to login with user : postgres and password : created above might give the error :

"Login disallowed for security reasons"

To fix this edit /usr/share/phppgadmin/conf/config.inc.php

and change :

$conf['extra_login_security'] = true;
to
$conf['extra_login_security'] = false;

Now login should work fine. The extra_login_security option disables the login of only certain usernames like psql, postgress, root and administrator. Alternatively create a separate user.

Resources

https://help.ubuntu.com/community/PostgreSQL





Last Updated On : 25th March 2009

Subscribe to get updates delivered to your inbox

About Silver Moon

Php developer, blogger and Linux enthusiast. He can be reached at [email protected]. Or find him on

8 Comments + Add Comment

  • thanks working ..

  • doesn’t work

    • which part is not working ?

    • /etc/apche2/conf.d/phppgadmin.conf -> allow access from YOUR IP/CIDR

  • Forbidden

    You don’t have permission to access /phppgadmin on this server.

  • In following the organization of phpmyadmin to access http://localhost/phppgadmin, you can also do the following:

    sudo ln -s /etc/phppgadmin/apache.conf /etc/apache2/conf.d/phppgadmin.conf

    sudo /etc/init.d/apache2 restart

  • Let me know the issue/error.

  • Doesn’t work.

Leave a comment