PostgreSQL is a powerful and reliable object-relational database system. It’s a great alternative for MySQL. It is as easy to set up, performs better and offers far more features.
1. Make sure you already have install python-software-properties
$sudo apt-get install python-software-properties
2.Add PPA repository to my Ubuntu.
$sudo add-apt-repository ppa:pitti/postgresql
3. After adding PPA, update your system apt:
$sudo apt-get update
4.Finally install postgresql-9.1:
$sudo apt-get install postgresql
if you having any error, make sure you already install libpq-dev.The libpq-dev package is for compiling wrappers/clients against libpq.
$sudo apt-get install postgresql-9.1 libpq-dev
5.Now check it out installation is successful or…..
$ locate postgresql
6. If done!!!, Cheers ………….. Check the install version.
$psql -V
7.Now let’s take look to postgres console
$su postgres
7(a) Setup Root User ‘posrgres’
$sudo passwd postgres give the postgres user a (unix) password,Now we can switch to the user postgres using command $ su postgres
8. That’s it for postgers installation. If you want to access postgres from remote, Mean localhost. You need to perform some addition setting to postgres conf file.
First we edit the file postgresql.conf:
$ cd /etc/postgresql/9.1/main
List all file in main folder
$ ls -la
total 80
drwxr-xr-x 2 postgres postgres 4096 2012-05-17 18:05 .
drwxr-xr-x 3 postgres postgres 4096 2012-04-07 12:44 ..
-rw-r–r– 1 postgres postgres 316 2012-04-07 12:44 environment
-rw-r–r– 1 postgres postgres 143 2012-04-07 12:44 pg_ctl.conf
-rw-r—– 1 postgres postgres 4653 2012-05-17 18:05 pg_hba.conf
-rw-r—– 1 postgres postgres 4649 2012-04-09 19:29 pg_hba.conf.bak.original
-rw-r—– 1 postgres postgres 1636 2012-04-07 12:44 pg_ident.conf
-rw-r–r– 1 postgres postgres 19235 2012-04-07 12:44 postgresql.conf
-rw-r–r– 1 postgres postgres 19235 2012-04-09 19:29 postgresql.conf.bak.original
-rw-r–r– 1 postgres postgres 378 2012-04-07 12:44 start.conf
I have already back of config file, you need to make back up for further need
$ cp pg_hba.conf pg_hba.conf.bak.original
$ cp postgresql.conf postgresql.conf.bak.original
9. Make changes to pg_hba.conf (authetification methods).
host all all 127.0.0.1/32 trust # md5 -> trust 10.You make change in config file, So once restart you postgres
$sudo /etc/init.d/postgresql restart * Restarting PostgreSQL 9.0 database server That's it. Enjoy.........
May 22, 2012 @ 12:49:52
I want to make database application based on web, how can I connect php and postgres on ubuntu ? thanks
May 24, 2012 @ 17:56:07
Frankly I never use PostgreSQL with php, I used postgres as ROR development. but hope this link will help you. http://www.techrepublic.com/blog/howdoi/how-do-i-use-php-with-postgresql/110
Jun 15, 2012 @ 23:40:35
Errata: I believe that point number 9 should read
“9. Make changes to pg_hba.conf”
instead of
“9.Make changes to pg_hba.config”
This is a nice and concise set of instructions for installing postgreSQL. I found them quite useful. Thanks.
Jun 16, 2012 @ 03:03:01
Thank you, I updated it. and I am glad you found it worth
Jun 24, 2012 @ 03:37:57
good information. thanks for posting.http://www.hpbrasil.org
Jul 02, 2012 @ 02:49:49
Hi Ennya, You most welcome.
Jul 21, 2012 @ 07:09:51
thanks man!! worked pefectly…
Do I have any idea about a “phpmyadmin” like tool for postgresql, which I can use for the postgresql installation I made using the instructions from this post ?
Jul 25, 2012 @ 18:20:01
i hope this link help you. http://www.techrepublic.com/blog/howdoi/how-do-i-use-php-with-postgresql/110
Aug 02, 2012 @ 20:35:02
if you are missing /etc/postgresql/9.1/main folder and postgre won’t start, after step 5 do
pg_createcluster 9.1 main –start
Oct 02, 2012 @ 15:35:25
Great work Pravin….all of your posts including this one are very informative and provide real help to rails community!
Oct 02, 2012 @ 16:10:49
Thanks for your time.
PostgreSQL, Ubuntu, NetBeans IDE (Part 1) | Strategic HR
Nov 18, 2012 @ 08:37:46
Hibernate, PostgreSQL, Ubuntu, NetBeans IDE (Part 1) | Strategic HR
Nov 21, 2012 @ 08:38:24
Dec 14, 2012 @ 20:53:55
help me please, my folder /etc/postgresql does not exists, help me!
Jan 23, 2013 @ 09:36:03
many Thanks its work successfully
Installing Postgresql in ubuntu | My Blog
Jan 24, 2013 @ 04:36:42
Feb 12, 2013 @ 22:46:12
And when at step 7 you are asked for a password…? Is there a default? If not, how do you set it? Without those small pieces of information this is useless.
Feb 13, 2013 @ 02:44:25
Right, Just now updated post. Thanks for comment.
Mar 14, 2013 @ 09:36:04
I want to add a new user to postgres with the sentence: createuser openerp70. But I have a bucle saying: Please answer “y” or “n”, and I cant do anything. What happens? I need to add a new user to do the connection to the database.
Thanks!!
Mar 15, 2013 @ 04:46:38
hey, you are missing space. Command should be-> CREATE USER username
CREATE USER openerp70
http://railskey.wordpress.com/2012/04/13/postgres-commands/
May above link helps you.
Apr 22, 2013 @ 14:15:00
Make changes to pg_hba.conf (authetification methods).
how to do it?
Apr 22, 2013 @ 16:52:38
hey, follow below steps.
1. cd /etc/postgresql/9.1/main
2. cp pg_hba.conf pg_hba.conf.bak.original
3. cp postgresql.conf postgresql.conf.bak.original
4. sudo gedit pg_hba.conf OR sudo vi pg_hba.conf OR sudo nano pg_hba.conf
will open the file, modify as per mention.
I hope it helps you, let me know if you have any further issues.
Apr 22, 2013 @ 17:18:51
thx u for answering my question ,after i tried i gt [sudo] password for postgres:
postgres is not in the sudoers file. This incident will be reported.
postgres is not in the sudoers file.<—how to solved it?
Apr 22, 2013 @ 20:29:16
Have you done below step?
7(a) Setup Root User ‘posrgres’
$sudo passwd postgres
give the postgres user a (unix) password,Now we can switch to the user postgres using command
$ su postgres
Apr 22, 2013 @ 22:30:07
ya,i ady done the step…
Apr 30, 2013 @ 13:38:01
Thanks .