Reputation: 9123
When I perform sudo -u zorgan postgres psql
to start my postgres session it returns:
postgres: invalid argument: "psql"
if I remove psql
it returns:
postgres does not know where to find the server configuration file.
You must specify the --config-file or -D invocation option or set the PGDATA environment variable.
Any idea what the problem is?
Upvotes: 1
Views: 5441
Reputation: 51446
https://www.sudo.ws/man/1.8.18/sudo.man.html
[-u user] [command]
so in your case:
sudo -u zorgan postgres psql
tries to start postgres process with argument psql
and thankfully fails.
if you want to connect to postgres cluster using psql
client, use psql
. so if you wish to run it with sudo:
sudo -u zorgan psql postgres
here postgres is argumentfor psql, which is dbname...
https://www.postgresql.org/docs/current/static/app-psql.html
psql [option...] [dbname [username]]
Upvotes: 1