Skip to content

Instantly share code, notes, and snippets.

@ondrej-kvasnovsky
Created November 8, 2018 20:28
Show Gist options
  • Save ondrej-kvasnovsky/6545f29216250b95a3f348923e1bc698 to your computer and use it in GitHub Desktop.
Save ondrej-kvasnovsky/6545f29216250b95a3f348923e1bc698 to your computer and use it in GitHub Desktop.
Remove Postgres and start it in docker
brew doctor
brew update
brew services list
brew services stop postgres
brew uninstall postgres
rm -rf /usr/local/var/postgres
rm -rf /usr/local/opt/postgresql
rm -rf .psql_history .psqlrc .psql.local .pgpass .psqlrc.local
# then use docker to start local postgres to avoid all these issues with running postgres on your local
docker run --name my-postgres -e POSTGRES_PASSWORD=password -d postgres
# get config
docker run -i --rm postgres cat /usr/share/postgresql/postgresql.conf.sample > my-postgres.conf
docker rm my-postgres
# update DB config
docker run -d -p 5432:5432 --name my-postgres -v "$PWD/my-postgres.conf":/etc/postgresql/postgresql.conf postgres -c 'config_file=/etc/postgresql/postgresql.conf'
# you can connect to DB using the following command
docker run -it --rm --link my-postgres:postgres postgres psql -h postgres -U postgres
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment