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.
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.
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';\""
sudo -u postgres "psql -c \"CREATE USER vagrant WITH PASSWORD 'vagrant';\""
seems that it would work just fine. –
Unwarranted could not change directory to "/root": Permission denied
so it's better to run sudo with -i
like this: sudo -i -u postgres psql -c "CREATE USER myuser WITH PASSWORD 'myuser1234';"
–
Kaycekaycee To run it on the original docker image for example you can use the su -c
command with the postgres
user in combination with psql:
su -c "psql -c \"CREATE ROLE my_user WITH LOGIN PASSWORD 'my_password' \"" postgres
© 2022 - 2024 — McMap. All rights reserved.