0

I am using

sudo pg_createcluster -u=$USER --datadir=candisDatabase -l=candisDatabase/candis.psql.log 9.6 candisCluster

to create a new database cluster with the specified directory as candisDatabase under the account $USER (which is 'rupav').

pg_lsclusters
Ver Cluster        Port Status Owner    Data directory               Log file
9.6 candisCluster2 5433 online   rupav    candisDatabase               candisDatabase/candis.psql.log
9.6 main           5432 online postgres /var/lib/postgresql/9.6/main /var/log/postgresql/postgresql-9.6-main.log

cluster is created successfully, and am able to run/start the new cluster and server candisCluster2 with pg_ctlcluster 9.6 candisCluster2 start successfully

following is the status of the new cluster (using pg_ctlcluster 9.6 candisCluster2 status) :

/usr/lib/postgresql/9.6/bin/postgres "-D" "candisDatabase" "-c" "config_file=/etc/postgresql/9.6/candisCluster2/postgresql.conf"

Now that server is listening on 5433 port, how can I add create role, database and password in the given cluster. By default (after postgresql installation) I can do sudo -u postgres psql to enter into the psql shell.

In short, I would like to have all my tables in the data directory specified, as candisDatabase which is owned by user different from postgres.

System details: I am on 'Ubuntu 17.10 (Oracle VM, host being windows)' and postgresql version is 9.6

rupav jain
  • 645
  • 1
  • 7
  • 13
  • given that you specified user you probably don't want to su to postgres, su to the user instead. – Jasen Jul 22 '18 at 05:16

1 Answers1

0

Given that you specified user you don't want to su to postgres, su to the user you specified instead.

if it's you just do

psql "port=5433 dbname=postgres"
Jasen
  • 11,837
  • 2
  • 30
  • 48
  • Ok, so since I am already logged in as the user, 'rupav', I typed `psql`, which gave me output as : "psql: FATAL: role "rupav" does not exist" – rupav jain Jul 22 '18 at 05:28
  • you need to specify the port number of the new cluster – Jasen Jul 22 '18 at 05:32
  • output of running `psql "port=5433 dbname=postgres"`: ``` psql: could not connect to server: No such file or directory Is the server running locally and accepting connections on Unix domain socket "/var/run/postgresql/.s.PGSQL.5433"? ``` – rupav jain Jul 22 '18 at 05:41
  • pg_lsclusters output currently: ``` Ver Cluster Port Status Owner Data directory Log file 9.6 candisCluster 5433 online rupav /home/opensource/candis/candisDatabase /home/opensource/candis/candisDatabase/candis.psql.log 9.6 main 5432 online postgres /var/lib/postgresql/9.6/main /var/log/postgresql/postgresql-9.6-main.log ``` – rupav jain Jul 22 '18 at 05:42