のんびりしているエンジニアの日記

ソフトウェアなどのエンジニア的な何かを書きます。

PostgreSQLのHomebrewでのインストール方法

Sponsored Links

皆さんこんにちわ
データベース関係のソフトウェアにはMySQL以外にも
PostgreSQLと呼ばれるソフトウェアもあります。

さて、インストールしてみましょう。
今回もHomebrewを使用します。

インストール方法

brew install postgresql
initdb /usr/local/var/postgres
ln -sfv /usr/local/opt/postgresql/*.plist ~/Library/LaunchAgents
launchctl load ~/Library/LaunchAgents/homebrew.mxcl.postgresql.plist

たまに、以下のようなエラーが出る時があります。

psql: could not connect to server: Connection refused
	Is the server running locally and accepting
	connections on Unix domain socket "/tmp/.s.PGSQL.5432"?

その場合は以下のコマンドを実行すれば解決できることもあります。

rm -rf /usr/local/var/postgres
initdb /usr/local/var/postgres
pg_ctl -D /usr/local/var/postgres -l logfile start

なんか、意外に面倒だった。

実行は以下のような感じです。

createdb temp
psql temp
psql (9.3.2)
Type "help" for help.

temp=#