I've got a Mac running OS X Lion (10.7.5), with PostgreSQL 9.2.4 installed. I've initialized a database cluster and started a server, all as the
postgres user. When I try to access certain directories related to my PostgreSQL installation, or execute certain binaries, I need to switch to the
postgres user first. For instance:
# Ideally I'd want this to work: my_name$ psql psql: FATAL: role "my_name" does not exist # I'd settle for this working, but it doesn't my_name$ sudo psql psql: FATAL: role "root" does not exist # I don't understand why this doesn't work but the next things does my_name$ sudo su postgres psql /opt/local/lib/postgresql92/bin/psql: /opt/local/lib/postgresql92/bin/psql: cannot execute binary file # This works my_name$ sudo su postgres sh$ psql psql (9.2.4) Type "help" for help.
my_name$ cd /opt/local/var/db/postgresql92/defaultdb -bash: cd: /opt/local/var/db/postgresql92/defaultdb/: Permission denied my_name$ sudo su postgres cd /opt/local/var/db/postgresql92/defaultdb my_name$ pwd /Users/my_name my_name$ sudo su postgres sh$ cd /opt/local/var/db/postgresql92/defaultdb sh$ pwd /opt/local/var/db/postgresql92/defaultdb
- Why does
sudo su postgres <cmd>not work, but when I separate the steps of switching the user and then invoking the command, it does work?
- Is there another way around this so that I don't have to switch users every time?
- More generally, is there a way to give a user all the permissions of another user in addition to the ones it already has? E.g. can I add all of the
postgresuser's permissions to the