I am using Ubuntu 12.04 and Postgress 9.2.
I need to create this user with this password e.g.
postgres://admin:[email protected]:5432
How to do that from the command line? I need to automate with a bash script. I have a fresh install.
Username [postgres]: The default username for postgres is postgres. (If you are using Advanced Server it is enterprisedb.) On a Mac or Windows, you are able to connect to the default instance by simply hitting enter at the shell or command prompt when trying to run psql and keying in the password.
Click in the Email field, and provide an email address for the user. Use the drop-down list box next to Role to select whether a user is an Administrator or a User. Select Administrator if the user will have administrative privileges within the pgAdmin client. Select User to create a non-administrative user account.
This will create user admin with password test101 on localhost:
psql -c "CREATE USER admin WITH PASSWORD 'test101';"
To run it from any user just add the sudo -u postgres
to it:
sudo -u postgres bash -c "psql -c \"CREATE USER vagrant WITH PASSWORD 'vagrant';\""
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