We help IT Professionals succeed at work.

How to connect to the correct DB server if there are multiple PostgreSQL DB server running on the same host?

kinna_giraffe
on
Hi:
      I have created a second database cluster on my linux host and started the DB server. Together with the another DB server installed earlier, I have two database server running on the same host with different port number.

     I tried to create DB in the second data directory, but it automatically created the DB in the first DB which was created much earlier.

     My question is how to utilize the second server and create DB.

BR
Xiaobei
Comment
Watch Question

Commented:

You use:
createdb -p port
http://www.postgresql.org/docs/8.2/static/app-createdb.html
Also when you start the second server you can give it:
-D /path/to /new/data/directory -p port
http://www.postgresql.org/docs/8.2/static/app-postgres.html

Cheers,
za-k/
Commented:
Another option is to use psql:

$ psql -p 1234 myacct
...
myacct=# CREATE DATABASE ...

("1234" is the port, and "myacct" is the user account that I created earlier)

Explore More ContentExplore courses, solutions, and other research materials related to this topic.