I have a shell script which runs on deployment and I have these lines:
# Database
createdb $DBNAME
createuser -D -A $DBNAME
However, in my logs I get this error:
- createdb: could not connect to database postgres: FATAL: Ident
authentication failed for user “root” - createuser: could not connect to database postgres: FATAL: Ident authentication failed for
user “root”
Would anyone mind telling me what is going wrong here and how I can correct my lines. Surely root should have permission to do this?
the best way to do this, especially if you want your script to be portable, is:
this should be safer, more secure, and more portable than using
-U. i do it this way in all my posgreSQL scripts. you might find it a useful technique. obviously it still needs to be run as a root user (e.g. withsudo).