There error is telling ... The problem is that you ran initdb as your local login, but I'm pretty that your login (username
) doesn't have access to /var/run/postgresql
. If you have a clean install, may I recommend that you remove the data directory and start all over, this time by su-ing into the postgres account:
username@jupiter:~$ sudo su - postgres
Then you can initdb
postgres@jupiter:~$ /usr/lib/postgresql/8.4/bin/initdb --encoding=UTF8 --pgdata=/mydata/pgdbdata/
Also, as Catcall mentioned, make sure you're using the correct location for your data.
It appears you have an 8.4 database that isn't managed by pg_wrapper
, and have installed 9.2 from Ubuntu packages and allowed it to create a pg_wrapper
managed cluster in the default location, which isn't where you want the DB.
pg_upgradecluster
from pg_wrapper
isn't suitable for this, since you hand-initdb'd the old cluster.
If the 9.2 cluster doesn't have any data of value in it yet, drop it, destroying all its data:
pg_dropcluster 9.2 main
Then re-create it in the desired location. Assuming your mounted HD's root is /mydata
, you'd:
pg_createcluster -d /mydata/pgdata_9.2_main 9.2 main
Now dump the old database and load it into the new one. Start both 8.4 and 9.1 on different ports; I'll assume 8.4 is on 5432 (default) and 9.2 is on 5433. Something like this should copy the dump from one directly into the other. Make sure you use the 9.1 versions of pg_dumpall
and psql
:
sudo -u postgres pg_dumpall -p 5432 | sudo -u postgres psql -p 5433
... but personally I'd do a pg_dumpall --globals-only
using the 9.2 pg_dumpall
against the 8.4 DB, followed by individual pg_dump
s of each database in the old cluster (again using the 9.2 pg_dump
). I'd then restore the globals dump followed by each individual dump into the new cluster.
Alternately, you can drop the pg_wrapper
managed 9.2 cluster, not re-create it, and follow the instructions for pg_upgrade
to do a binary upgrade from the 8.4 to the 9.2 DB. This will create a DB that is not managed by pg_wrapper
. You can either convert it to be managed by pg_wrapper
by moving and symlinking postgresql.conf
and pg_hba.conf
, or you can just manage it like you did 8.4, using your own init scripts.
Best Answer
Ubuntu or Debian can run multiple instances of PostgreSQL and provide a specific way to autostart/stop/start each cluster.
There should be a file named
start.conf
inside/etc/postgresql/9.2/main
(or more generally /etc/postgresql/<version>/<clustername>) with these self-explanatory contents:If you replace auto by manual, you could start this PostgreSQL instance only when desired with the command:
As for looking at the console, what you should want instead is having this run in a terminal when you work with the database: