Skip to content

Instantly share code, notes, and snippets.

@doabit
Forked from haknick/gist:7394776
Created December 1, 2013 12:29
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save doabit/7733058 to your computer and use it in GitHub Desktop.
Save doabit/7733058 to your computer and use it in GitHub Desktop.
# On Mavericks (same for 10.6+) the biggest issue is that port 5432 is already taken so
# this: --- config.vm.network "forwarded_port", guest: 5432, host: 5433' ---
# should go on 'Vagrantfile' and then you use port 5433 to connect through pgadmin3
echo >&2 "===CUSTOM-MSG=== Setup THE DATABASE"
# installs postgresql database and creates "vagrant" superuser with password "somepass".
sudo apt-get -y install postgresql postgresql-client libpq-dev
echo >&2 "===CUSTOM-MSG=== Create role and login"
sudo su postgres -c "psql -c \"CREATE ROLE vagrant SUPERUSER LOGIN PASSWORD 'somepass'\" "
# create database 'mynewdb' for role (superuser) vagrant
echo >&2 "===CUSTOM-MSG=== Create db"
sudo su postgres -c "createdb -E UTF8 -T template0 --locale=en_US.utf8 -O vagrant mynewdb"
# enable the db to listen from the host through tcp
sudo su postgres -c "printf \"\n\n# === CUSTOM VAGRANT SETTINGS === \n \" >> /etc/postgresql/*/main/postgresql.conf"
sudo su postgres -c "echo \" listen_addresses = '*' \" >> /etc/postgresql/*/main/postgresql.conf"
sudo su postgres -c "printf \"\n\n# === CUSTOM VAGRANT SETTINGS === \n \" >> /etc/postgresql/*/main/pg_hba.conf"
sudo su postgres -c "echo \" host all all 10.0.2.2/24 md5 \" >> /etc/postgresql/*/main/pg_hba.conf"
#restart
sudo /etc/init.d/postgresql restart
@TapiwaChikwenya
Copy link

Hey so when you put connection parameters in pgadmin what format are you setting those this?
postgress

@doabit
Copy link
Author

doabit commented Apr 7, 2022

Hey so when you put connection parameters in pgadmin what format are you setting those this? postgress

Sorry, i've not use Vagrant too many years.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment