Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to connect to an alternative local postgresql cluster for the fist time?

Tags:

postgresql

In Ubuntu 16.04 I created second postgres database cluster, called cmg, with a local user as the admin user:

pg_create -u "local_username" -g "local_usergroup" -d /path/to/data/dir 9.5  cmg

The cluster was started with:

pg_ctrlcluster 9.5 cmg start

which ran successfully (pg_lsclusters show both are online)

The problem is I cannot connect to the cluster using psql as is normally done.

I tried using:

psql -h 127.0.0.1 -w -p5433  -U local_username

which fails with:

psql: fe_sendauth: no password supplied"

Is there any way to connect to the specific cluster?

like image 300
Marked Avatar asked Sep 19 '17 13:09

Marked


1 Answers

use psql -h your_socket_dir -p5433 -U postgres to connect locally (uses peer auth by default - thus high chahce to login wothout password)

once logged in - set up password (create user if needed) and use it connecting remotely

psql -h 127.0.0.1 -p5433  -U local_username

in your connect string you had -w which is never ask for a password https://www.postgresql.org/docs/current/static/app-psql.html which would by default work only for local connections

like image 146
Vao Tsun Avatar answered Oct 03 '22 17:10

Vao Tsun