LoginSignup
35

More than 5 years have passed since last update.

postgreSQLの構築

Posted at

アンインストール

1.homebrewでインストールしたpostgresqlを削除

    brew uninstall postgresql

2.データベースクラスタの削除

initdbで初期化する際、既に存在する場合にエラーとなるので、事前にフォルダを削除しておく必要がある。

    rm -rf /usr/local/var/postgres

インストール

1.homebrewでインストール

完了するまで待機(make処理等で5分くらい掛かる)

    brew install postgresql

2.データベースクラスタの初期化

英語、日本語圏ではlocale設定は意味がないので使用しない。
(ソート処理が遅くなる等の弊害があるので--no-localeオプションを忘れずにつけること)

    initdb /usr/local/var/postgres -E utf8 --no-locale

データベース一覧が取得出来ればインストール成功

    psql -l

3.自動起動の設定

    ln -sfv /usr/local/opt/postgresql/*.plist ~/Library/LaunchAgents
    launchctl load ~/Library/LaunchAgents/homebrew.mxcl.postgresql.plist

4.環境変数の設定

環境変数PGDATAの設定。bashなら~/.bash_profile

~/.bash_profile
    export PGDATA=/usr/local/var/postgres

参考サイト

 ロケールの設定要否について
 http://www.atmarkit.co.jp/ait/articles/0806/10/news144_2.html

http://codenote.net/mac/homebrew/187.html
http://masutaka.net/chalow/2014-02-01-1.html
http://succzero.hatenablog.com/entry/2014/09/21/133315
http://morizyun.github.io/blog/postgresql-mac-centos-rails/
http://b.pyar.bz/blog/2014/10/21/mac-postgresql-installation/

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
35