PostgreSQL
PostgreSQL configuration
Note: if you know postgres admin credentials but do not know the configuration details of an existing installation, this is a very handy DDL that will list all configration information:
select category, name, seting from pg_settings order by 1;
1. Installation
- sudo apt-get install postgresql postgresql-client postgresql-contrib (This installs the database server/client, some extra utility scripts)
- sudo apt-get install pgadmin3 (This installs the pgAdmin GUI application for working with the database)
- References
2. Configuration
- To allow localhost connections to all databases from any user without password authentication, edit your pg_hba.conf file to include these entries.
- local all all trust  (unix installs only)Â
- host all 127.0.0.1/32 trust
- host all all ::1/128 trust (windows only - ipv6 section)Â
- Comment IDENT-based authentication
- Otherwise, the following error message will be popped up: "psql: FATAL:Â Ident authentication failed for user "[userid]" "
3. Files
- /etc/postgresql/8.3/main/pg_hba.conf
4. Commands
- Server management
- sudo /etc/init.d/postgresql-8.3 stop
- sudo /etc/init.d/postgresql-8.3 start
- sudo /etc/init.d/postgresql-8.3 restart
- Connect to a database
- psql -U postgres template1
- Create user
- Login using postgres
- Run SQL:Â
- create user [userid] WITH CREATEDB;
- GRANT USAGE ON LANGUAGE plpgsql TO tdar;
- Create database
- Login with [userid]: psql -U [userid] template1
- Run SQL: create database [db1]