Pages

Friday, 17 October 2014

Set Up PostgreSql On Ubuntu

sudo apt-get install postgresql postgresql-contribsudo apt-get install libpq-devsudo -u postgres createuser --superuser tarunsudo -u postgres psqlpostgres=# \password tarunpassword: tarunenter again password: tarun\qClient programs, by default, connect to the local host using your Ubuntu login name and expect to find a database with that name too. So to make things REALLY easy, use your new superuser privileges granted above to create a database with the same name as your login name: sudo -u postgres createdb tarunConnecting to your own database to try out some SQL should now be as easy as: psqlCreating additional database is just as easy, so for example, after running this: create database mmagap; If you get the below error after restart the server

psql: FATAL: Peer authentication failed for user "postgres"

Switch to postgres user

$ sudo su - postgres #it will ask for password and by default password is also postgres

After switch the user to postgres, open psql console

$ psql

so check the version of postgres if multiple versions are available

psql=# select VERSION();

PostgreSQL 9.1.13 on x86_64-unk.... # so version is 9.1

Now Open From postgres user

vim /etc/postgresql/9.1/main/pg_hba.conf # 9.1 is version return form upper command