środa, 26 października 2011

Install Postgres-8.4 Debian 6

apt-get update
apt-get install debian-backports-keyring
apt-get install -t lenny-backports postgresql-8.4 phppgadmin

You'll notice that I've added phppgadmin (a Php written frontend for the DB, somewhat similar to the mysql one), remove it in case you didn't need it or hadn't Apache installed).
Let's go on with the shell! (commented lines will briefly explain what happens)

#let's stop the main daemon to avoid mess
/etc/init.d/postgresql-8.4 stop

# now let's login as the postgres user (in order to start interacting with the db)
# By default uses the same pwd as root, maybe better changing it (for clarity I'll add postgres$ before the commands)

su postgres

# this command will allow us to initiate a new database in a custom location (/my/db/path/ has to be replaced with your personal one)

postgres$ /usr/lib/postgresql/8.4/bin/initdb -D /my/db/path/

# once created our shiny new base, let's create a user to start using it (give it admin rights when prompted)

postgres$ createuser pguser

# let's change the new user's password. psql command connects to the new db and allows to manage it

postgres$ psql postgres

# once logged into the db use this command to change new user's passphrase

template1=# \password pguser;
template1=# \q

#let's get back to our root

postgres$ exit

#this passage is fundamental to get things working, it links our custom db's conf to the one the daemon will read

ln -s /my/db/path/postgresql.conf /etc/postgresql/8.4/main/postgresql.conf

Don't forget to replace ConfigDir with your personal one, on /my/db/path/postgresql.conf

Now, in order to use Phppgadmin safely, we've to change the default security behavior (if not Phppgadmin will accept random passwords to login)
On our /my/db/path/pg_hba.conf we'll have to look for the last lines where the hosts are listed and change METHOD to md5 (default should be trust)
Let's finally start the DB

/etc/init.d/postgresql-8.4 start

Brak komentarzy:

Prześlij komentarz