This commit is contained in:
2025-12-09 22:03:58 -06:00
parent 565b3d3b6d
commit c16d9743a2
2 changed files with 141 additions and 0 deletions

79
set-postgres-password.sh Executable file
View File

@@ -0,0 +1,79 @@
#!/bin/bash
# Interactive PostgreSQL Password Setup Script
echo "=========================================="
echo "PostgreSQL User Password Setup"
echo "=========================================="
echo ""
echo "Available users:"
echo " 1. postgres (superuser - recommended)"
echo " 2. skyartapp"
echo " 3. songlyric_app"
echo " 4. songlyric_user"
echo ""
read -p "Select user number (1-4): " user_choice
case $user_choice in
1)
username="postgres"
;;
2)
username="skyartapp"
;;
3)
username="songlyric_app"
;;
4)
username="songlyric_user"
;;
*)
echo "Invalid choice. Exiting."
exit 1
;;
esac
echo ""
echo "Setting password for user: $username"
echo ""
# Prompt for password (hidden input)
read -s -p "Enter new password: " password
echo ""
read -s -p "Confirm password: " password_confirm
echo ""
if [ "$password" != "$password_confirm" ]; then
echo ""
echo "Error: Passwords do not match!"
exit 1
fi
if [ -z "$password" ]; then
echo ""
echo "Error: Password cannot be empty!"
exit 1
fi
# Set the password
echo ""
echo "Setting password..."
sudo -u postgres psql -c "ALTER USER $username PASSWORD '$password';"
if [ $? -eq 0 ]; then
echo ""
echo "=========================================="
echo "Success! Password set for user: $username"
echo "=========================================="
echo ""
echo "You can now use these credentials in pgAdmin 4:"
echo " Host: 192.168.10.130"
echo " Port: 5432"
echo " Username: $username"
echo " Password: [the password you just entered]"
echo ""
else
echo ""
echo "Error: Failed to set password!"
exit 1
fi