0.预先安装HomeBrew
/usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
1. Install
安装好HomeBrew之后,使用
brew update&brew upgrade
更新后,便可以开始postgresql了。
brew install postgresql
创建postgreSql数据库:
initdb /usr/local/var/postgres
启动服务:
pg_ctl -D /usr/local/var/postgres -l /usr/local/var/postgres/server.log start
停止服务:
pg_ctl -D /usr/local/var/postgres stop -s -m fast
2.创建角色
createuser -d -a -P postgres
创建测试数据库
create database testdb;
3.测试连接
psql -Upostgres testdb;
网友评论