I am trying to do this in a script:
» sudo -u postgres createuser -PE -s user1
Enter password for new role:
I do not want postgres
to ask for the password interactively, so I want to do:
» sudo -u postgres createuser -PE -s user1 < /tmp/xxx
Where /tmp/xxx
contains the password for the new user. But it does not work. How to get this working?
You can do that using plain SQL after connecting as a superuser (e.g. postgres
) to the database in question:
create user user1 password 'foobar'
If you need to do this from within a script you can put that into a sql file and then pass this to psql:
» sudo -u postgres psql --file=create_user.sql
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With