Postgresql安装

shell> brew install postgresql
# 初始化
shell> initdb /Users/kendo/LocalDB/LocalPostgreSQL -E utf8
shell> ln -s /usr/local/Cellar/postgresql/12.2_1/homebrew.mxcl.postgresql.plist ~/Library/LaunchAgents/
shell> launchctl load ~/Library/LaunchAgents/homebrew.mxcl.postgresql.plist
shell> pg_ctl -D /usr/local/var/postgres start|restart|stop
# 创建用户,命令行直接运行
shell> createuser kendo -P
# 创建数据库erp,指定拥有者为kendo,编码utf8,-e 是指把数据库执行操作的命令显示出来
shell> createdb erp -O kendo -E UTF8 -e
# 链接数据库
shell> psql -U kendo -d erp -h 127.0.0.1
erp=#: