Sunday, January 10, 2016

Installation and Setup of PostgreSQL in Ubuntu


First, install postgresql and commonly used add-on's. 


> sudo apt-get install postgresql postgresql-contrib
 
If you plan to use the pgAdmin tool as the GUI front-end for your database, then execute 
the following command: 

> sudo apt-get install pgadmin3
 
The basic installation creates a "postgres" user as the root user to access PostgreSQL. 
But it doesn't setup an password. So we'll have to setup a password for this user.
 
> sudo -u postgres psql postgres 
 
Set a password for the "postgres" database role using the command: 
 
# \password postgres 
 
You're all set up to play around and start using PostgreSQL in your linux environment now!
 

Create a database by running "createdb" command:

> sudo -u postgres createdb
 
If you have an import sql script, you can load that by running 
 
> sudo -u postgres psql <  

You can also execute sql commands by simply starting up the sql console via 

> psql

followed by 
# create database 
... 
 
 
To allow connections to your database server, you'd probably have to make a minor change to 
your pg_hba.conf file. 
 
Replace "peer" with "md5" in the following line in your 
/etc/postgresql/9.3/main/pg_hba.conf file: 
 
# Database administrative login by Unix domain socket
local    all       postgres                           peer

Reload the configuration changes for it to be effective:

> sudo /etc/init.d/postgresql reload

To enable postgresql to listen across networks other than local, modify the listen_address 
in the following file:

/etc/postgresql/current/main/postgresql.conf [listen_address = '*']
 

1 comment:

  1. Play Spades card games - DrmCD
    Spades is 전라남도 출장샵 a popular trick-taking card game. There are 사천 출장안마 52 decks of playing cards and 김제 출장마사지 52 decks of playing cards. There are 52  Rating: 3.9 전라북도 출장샵 · ‎16 사천 출장샵 votes

    ReplyDelete