Pages

Showing posts with label sql. Show all posts
Showing posts with label sql. Show all posts

Monday, January 28, 2008

Getting strat PostgreSQL 8.2.6

Settings for PostgreSQL in Ubuntu 7.04 (Feisty Fawn)

1. create user
$ su -
# su - postgres
$ createuser husylvan
$ su - husylvan


2. create cluster
$ sudo pg_createcluster -u husylvan -d ~/pgdata 8.2 pgdata

*Configuration files(postgresql.conf, pg_hba.conf, and pg_ident.conf) are in /etc/postgresql/8.2/pgdata/

3. start PostgreSQL server
$ pg_ctlcluster 8.2 pgdata start


4. create database
$ createdb mydb


5. start PostgreSQL interactive terminal
$ psql mydb

* commands introduced by TA are in /usr/lib/postgresql/8.2/bin
** for ruby on rails
$ sudo gem install ruby-postgres -- --with-pgsql-include-dir=/usr/include/postgresql --with-pgsql-lib-dir=/usr/lib/postgresql/8.2/lib


Settings for PostgreSQL in Mac OS

1. download PostgreSQL 8.2.5 for Mac OS
http://www.postgresqlformac.com

2. install server only
double click PostgreSQL.mpkg in Server folder

3. it will be installed in /Library/PostgreSQL8

4. change postgres account password
sudo passwd postgres

5. create my account role in the db
su -m postgres -c 'createuser Hwal'

6. create db using Create Database icon in Applications/PostgreSQL folder

# for ruby on rails
$sudo gem install ruby-postgres -- \
--with-pgsql-include-dir=/Library/PostgreSQL8/include \
--with-pgsql-lib-dir=/Library/PostgreSQL8/lib

## other way (not recommended)
$ initdb -D ~/Documents/ClassDocs/cs186/pgdata
$ pg_ctl -D ~/Documents/ClassDocs/cs186/pgdata start
$ createdb depot_development
$ psql depot_development
% CREATE TABLE countries (
name char(20),
latitude int,
longitude int,
area int,
population int,
gdp int,
gdpYear int);