建议用Homebrew安装postgreSQL
先安装Homebrew ,但是Homebrew依赖于Xcode Command Line Tools,所以需先打开终端执行:
xcode-select --install
在终端中执行安装Homebrew:
/usr/bin/ruby-e"$(curl-fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
检查是否已安装成功:
$ brew -v
Homebrew 1.6.1
Homebrew/homebrew-core (git revision 0aeb7; last commit 2018-04-12)
homebrew安装postgreSQL:
brew install postgresql
安装完postgresql之后需要初始化数据库:
initdb /usr/local/var/postgres -E utf8
如果你不初始化,那么db的路径就是上面的/usr/local/var/postgres(在MacOS 10.11上),数据库编码类型就是utf8.
设置开