Advertisement
Guest User

Set a random password for your postgres

a guest
May 31st, 2016
55
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 0.35 KB | None | 0 0
  1. #!/bin/bash
  2.  
  3. set -e
  4.  
  5. rand_number=`openssl rand -base64 32`
  6. POSTGRES_PASSWORD=${rand_number//\//} # Remove slashes other sed command with fail
  7. sudo -u postgres psql -U postgres \
  8.                       -d postgres \
  9.                       -c "alter user postgres with password '$POSTGRES_PASSWORD';"
  10. echo "Your postgres password is $POSTGRES_PASSWORD"
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement