1、安裝
打開MacBook命令行窗口,執行如下命令:
(1)查看可用版本Postgres
brew search postgresql
(2)安裝Postgres
brew install [email protected] -v
如果順利安裝成功,將會在安裝結束後輸出如下信息:
If you need to have [email protected] first in your PATH run:
echo 'export PATH="/usr/local/opt/[email protected]/bin:$PATH"' >> ~/.bash_profile
For compilers to find [email protected] you may need to set:
export LDFLAGS="-L/usr/local/opt/[email protected]/lib"
export CPPFLAGS="-I/usr/local/opt/[email protected]/include"
For pkg-config to find [email protected] you may need to set:
export PKG_CONFIG_PATH="/usr/local/opt/[email protected]/lib/pkgconfig"
To have launchd start [email protected] now and restart at login:
brew services start [email protected]
Or, if you don't want/need a background service you can just run:
pg_ctl -D /usr/local/var/[email protected] start
(3)配置Postgres
配置文件:
/usr/local/var/[email protected]/postgresql.conf
啓動:
brew services start [email protected]
停止:
brew services stop [email protected]
重啓:
brew services restart [email protected]