顯示具有 PostgreSQL 標籤的文章。 顯示所有文章
顯示具有 PostgreSQL 標籤的文章。 顯示所有文章

2015年9月16日 星期三

Mac安裝PostgreSQL與簡單教學

PostgreSQL和MySQL一樣都是一種SQL Server
以下有些教學是可以提供給會MySQL,也想使用PostgreSQL的使用者看看

第零步,安裝PostgreSQL

使用brew來安裝 (Linux的話就看是apt / yum 還是什麼的,以下以Mac為例)

brew install postgresql

成功的話,會看到最後有段訊息

To have launchd start postgresql at login:
  ln -sfv /usr/local/opt/postgresql/*.plist ~/Library/LaunchAgents
Then to load postgresql now:
  launchctl load ~/Library/LaunchAgents/homebrew.mxcl.postgresql.plist
Or, if you don't want/need launchctl, you can just run:
  postgres -D /usr/local/var/postgres


主要的重點是說,你想要一登入Mac的使用者,就自動啟動PostgreSQL的話,就在終端機輸入


ln -sfv /usr/local/opt/postgresql/*.plist ~/Library/LaunchAgents

要手動啟動 (第一次裝完最好也輸入一次)

launchctl load ~/Library/LaunchAgents/homebrew.mxcl.postgresql.plist

如果想要停止的話輸入

postgres -D /usr/local/var/postgres




第一步,建立Database
createdb 是 postgresql 建立資料庫的指令