Installation of PostgreSQL
Install PostgreSQL with the following commands:
./configure --prefix=/usr &&
make &&
make install
Initialize a database cluster with the following commands:
mkdir -p /var/pgsql/data &&
useradd -d /var/pgsql/data postgres &&
chown postgres /var/pgsql/data &&
su - postgres -c '/usr/bin/initdb -D /var/pgsql/data'
Start the database server with the following command:
su - postgres -c '/usr/bin/postmaster -D /var/pgsql/data > \
/var/pgsql/data/logfile 2>&1 &'
Now we can create a database and verify the installation:
su - postgres -c '/usr/bin/createdb test'
echo "create table t1 ( name varchar(20), state_province varchar(20) );" \
| (su - postgres -c '/usr/bin/psql test ')
echo "insert into t1 values ('Billy', 'NewYork');" \
| (su - postgres -c '/usr/bin/psql test ')
echo "insert into t1 values ('Evanidus', 'Quebec');" \
| (su - postgres -c '/usr/bin/psql test ')
echo "insert into t1 values ('Jesse', 'Ontario');" \
| (su - postgres -c '/usr/bin/psql test ')
echo "select * from t1;" | (su - postgres -c '/usr/bin/psql test')