1、安装
Mac下,PostgreSQL的安装可以直接通过homebrew进行:
brew search postgres
如上命令会检索出PostgreSQL相关的软件,如我们指定其中的PostgreSQL 9.6版本进行安装
brew install postgresql@9.6
值得一提的是,通过homebrew安装的程序,都会存储在/usr/local/Cellar目录下面,并将对应的应用软链接到/usr/local/opt目录下;
应用的配置和存储数据会放在/usr/local/var下的对应目录下(配置和数据不会随着卸载命令而删除)
2、启动
安装完后,会提示程序启动的方式,如下描述:
To have launchd start postgresql@9.6 now and restart at login:
brew services start postgresql@9.6
Or, if you don't want/need a background service you can just run:
pg_ctl -D /usr/local/var/postgresql@9.6 start
pg_ctl正因为可以直接执行是因为在brew在安装过程中,在当前目录的.bash_profile文件中写入