跳至主要内容

[PSQL] Getting Started

PostgreSQL Tutorial

安裝

# 透過 homebrew 安裝
$ brew install postgresql
$ brew services start postgresql
$ psql postgres

錯誤處理

突然連不上 db,重新安裝 postgres 的方式:Completely Uninstall and Reinstall PSQL on OSX

# https://medium.com/@bitadj/completely-uninstall-and-reinstall-psql-on-osx-551390904b86

# Make sure brew is happy
$ brew doctor
$ brew update

# Uninstall PostgreSQL using Homebrew
$ brew uninstall postgresql

# Remove all local PostgreSQL files
$ rm -rf /usr/local/var/postgres
$ rm -rf .psql_history .psqlrc .psql.local .pgpass .psqlrc.local

# Confirm that PostgreSQL is actually uninstalled
$ brew list

# reinstall postgres
$ brew update
$ brew install postgres
$ brew services start postgresql