1、安装
打开MacBook命令行窗口,执行如下命令:
(1)查看可用版本Postgres
brew search postgresql
(2)安装Postgres
brew install postgresql@9.5 -v
如果顺利安装成功,将会在安装结束后输出如下信息:
If you need to have postgresql@9.5 first in your PATH run:
echo 'export PATH="/usr/local/opt/postgresql@9.5/bin:$PATH"' >> ~/.bash_profile
For compilers to find postgresql@9.5 you may need to set:
export LDFLAGS="-L/usr/local/opt/postgresql@9.5/lib"
export CPPFLAGS="-I/usr/local/opt/postgresql@9.5/include"
For pkg-config to find postgresql@9.5 you may need to set:
export PKG_CONFIG_PATH="/usr/local/opt/postgresql@9.5/lib/pkgconfig"
To have launchd start postgresql@9.5 now and restart at login:
brew services start postgresql@9.5
Or, if you don't want/need a background service you can just run:
pg_ctl -D /usr/local/var/postgresql@9.5 start
(3)配置Postgres
配置文件:
/usr/local/var/postgresql@9.5/postgresql.conf
启动:
brew services start postgresql@9.5
停止:
brew services stop postgresql@9.5
重启:
brew services restart postgresql@9.5