Install Postgresql using Homebrew

Below are the procedures to install and configure Postgresql on mac using home-brew (Currently Postgresql 9.6.1)

  • Update Homebrew using command
    • $ brew update
  • Install postgresql
    • $ brew install postgresql
  • Initialize the database
    • $ initdb /usr/local/var/postgres/
  • Start the database server
    • $ pg_ctl -D /usr/local/var/postgres -l /usr/local/var/postgres/server.log start
      $ pg_ctl -D /usr/local/var/postgres/ -l logfile start
  • Create the database
    • $ created nameOfYourDatabase
  • Start the database
    • $ psql nameOfYourDatabase
  • Stop a database server
    • pg_ctl -D /usr/local/var/postgres stop -s -m fast

Using a LaunchAgent and plist to Launch PostgreSQL on Startup:

  • Create a directory for LaunchAgents (usually created by default)
    • $ mkdir -p ~/Library/LaunchAgents
  • Create symbolic link from launchAgents to Postgresql
    • $ ln -sfv /usr/local/opt/postgresql/*.plist ~/Library/LaunchAgents
  • Load the symbolic link file
    • $ launchctl load ~/Library/LaunchAgents/homebrew.mxcl.postgresql.plist

Notes:
When creating a new database system, either remove or empty
the directory /usr/local/var/postgres, or run initdb
with an argument other than /usr/local/var/postgres.

Reference:
* install PostgreSQL 9 in Mac OSX via Homebrew
* Install PostgreSQL on Mac OS X via Brew
* How to Start PostgreSQL Server on Mac OS X

评论 3
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值