On Thu, Aug 8, 2013 at 5:44 PM, Thomas Kellerer <spam_eater@xxxxxxx> wrote:
Don Parris wrote on 08.08.2013 23:13:You are not running the script as superuser because you supplied "-U user" and thus the _script_ is executed
And to be able to run it from the Bash prompt (as securely as possible).
I thought I could add the commands and run the create script by doing:
sudo -u postgres psql -U user -W -d mydb --file=/home/user/dev/mydb_create.sql
I thought that, running my script as the superuser, it would have the privileges necessary
to install the extension, but I still got a "permission denied" error.
as "user". psql is started as "postgres" (the Linux user, not the DB user).
My bad - forgot to change the example above to reflect accurately the user... I did use the postgres user.
I don't see the reason for using sudo in the first place, -U is enough:
Fair enough. But I think you are onto something here below...
Leave out the sudo, and use:
psql -U postgres -W -d mydb --file=/home/user/dev/mydb_create.sql
Or if you do want to use sudo, the leave out the -U user parameter:
sudo -u postgres psql -d mydb --file=/home/user/dev/mydb_create.sql
When I try a simple psql -U postgres -W - just to initiate the psql session, I get:
psql: FATAL: Peer authentication failed for user "postgres"
psql: FATAL: Peer authentication failed for user "postgres"
It's like my regular user cannot connect as the postgres user.
However, this works (with me just typing my password for sudo):
donp@wiesbaden:~$ sudo -u postgres psql -U postgres
[sudo] password for donp:
psql (9.1.9)
Type "help" for help.
postgres=# \q
donp@wiesbaden:~$ sudo -u postgres psql -U postgres
[sudo] password for donp:
psql (9.1.9)
Type "help" for help.
postgres=# \q
Maybe I have some permissions issues?
Thanks,
Don
Don