In a bash script I'm writing, I need to create a database and set a password that is generated automatically by my script.
The problem is I can't find a way to set up the password without user interaction.
I need something like this:
$ createdb mydb -p $(cat password_file)
Any ideas?
Best Answer
From the documentation:
This means that you can write a script which issues a command like
Where
createdb.sql
contains something likeThis means that you will have a user for every database created.
(At the same time I have a mild suspicion that your problem is what riouj answered.)