Friday, October 11, 2013

Installing PostGresql

1. Use the sudo command

$ sudo apt-get install postgresql

2. Basic Server Settings

$ sudo -u postgres psql postgres

postgres=# \password postgres


--Enter password.(twice)


Type Cntrl D to exit postgres prompt.



3. $ sudo apt-get install postgresql-contrib

4. Installing postgresql-contrib

$ sudo apt-get install postgresql-contrib

5. If $ psql -l
     throws the error:
     psql: FATAL:  role "user_name" does not exist

It means you have to create a new user and assign it superuser access.

$ sudo -u postgres createuser user_name


Then you are asked if you want to make this as the superuser. Choose as required.

6. $ psql -l

Gives
 List of databases
        Name        |  Owner   | Encoding |   Collate   |    Ctype    |   Access privileges  
--------------------+----------+----------+-------------+-------------+-----------------------



 ......some text........
 
 
 7. check
psql --version 
And you should get something like this: 
psql (PostgreSQL) 9.1.9
contains support for command-line editing
 
Enjoy! 
 
8. If the user wants to check all PostGresSQL clusters. Enter command:
$ pg_lsclusters

You get something like this:

Version Cluster   Port Status Owner    Data directory                     Log file
9.1     main      5432 down   postgres /var/lib/postgresql/9.1/main       /var/log/postgresql/postgresql-9.1-main.log

 
 
 

No comments:

Post a Comment