第一步:搜索
brew search postgresql
第二步:安装
brew install postgresql
可以看到如下信息:
第三步:添加软链接
mkdir -p ~/Library/LaunchAgents
ln -sfv /usr/local/opt/postgresql/*.plist ~/Library/LaunchAgents
第四步:启动
launchctl load ~/Library/LaunchAgents/homebrew.mxcl.postgresql.plist
第五步:创建用户和角色
createuser -s -r postgres
第六步:登录
psql postgres
第七步:修改密码
alter user postgres PASSWORD 'postgres';
第八步:退出
\q
启动数据库:
pg_ctl -D /usr/local/var/postgres -l /usr/local/var/postgres/server.log start
停止数据库:
pg_ctl -D /usr/local/var/postgres -l /usr/local/var/postgres/server.log stop