Fill these in once
- Create the user
psql postgres -c "CREATE USER myapp WITH PASSWORD 'change-me';" - Create the database, owned by that user
psql postgres -c "CREATE DATABASE myapp_dev OWNER myapp;" - Your connection string
echo "postgresql://myapp:change-me@localhost:5432/myapp_dev"Paste it into your app's .env as DATABASE_URL.
Check it worked
- Log in as the new user
psql -h localhost -U myapp -d myapp_dev -c "SELECT current_user, current_database();"
Undo it
- Delete the database and user
psql postgres -c "DROP DATABASE myapp_dev;" -c "DROP USER myapp;"
- Create the userNeeds sudo
sudo -u postgres psql -c "CREATE USER myapp WITH PASSWORD 'change-me';" - Create the database, owned by that userNeeds sudo
sudo -u postgres psql -c "CREATE DATABASE myapp_dev OWNER myapp;" - Your connection string
echo "postgresql://myapp:change-me@localhost:5432/myapp_dev"Paste it into your app's .env as DATABASE_URL.
Check it worked
- Log in as the new user
psql -h localhost -U myapp -d myapp_dev -c "SELECT current_user, current_database();"
Undo it
- Delete the database and userNeeds sudo
sudo -u postgres psql -c "DROP DATABASE myapp_dev;" -c "DROP USER myapp;"
- Create the user
psql -U postgres -c "CREATE USER myapp WITH PASSWORD 'change-me';"Asks for the postgres password you set during install.
- Create the database, owned by that user
psql -U postgres -c "CREATE DATABASE myapp_dev OWNER myapp;" - Your connection string
echo "postgresql://myapp:change-me@localhost:5432/myapp_dev"Paste it into your app's .env as DATABASE_URL.
Check it worked
- Log in as the new user
psql -h localhost -U myapp -d myapp_dev -c "SELECT current_user, current_database();"
Undo it
- Delete the database and user
psql -U postgres -c "DROP DATABASE myapp_dev;" -c "DROP USER myapp;"