MacBook AirにPostgreSQLをbrewでインストールした
MacにはもともとPostgreSQLが入っているっぽい。サーバは入ってないのかな。でも、psqlコマンドはある。
それは、置いておいて、brewでPostgreSQLをインストールしてみた。
$ brew install postgres
まぁ、こんだけ。
次にDatabaseの初期化
$ initdb /usr/local/var/postgres
んで、サーバの起動
$ pg_ctl start -D /usr/local/var/postgres
そして、psqlで接続しようとすると以下のエラーになった。
$ psql psql: could not connect to server: Permission denied Is the server running locally and accepting connections on Unix domain socket "/var/pgsql_socket/.s.PGSQL.5432"?
どうやらもともとインストールされてるpsqlを見に行ってしまっているらしい。
で、以下のサイトにこの問題を解決するスクリプトがあったので、実行してみたら、psqlコマンドがちゃんと動くようになりましたよ。
Brew Install Postgresql on OS X Lion – Nextmarvel
ダウンロードしたスクリプトを以下のように実行.
$ sh fixBrewLionPostgres.sh
それでもう一回psqlコマンドを実行(オプションが増えてるけど気にしないで)
$ psql -l List of databases Name | Owner | Encoding | Collate | Ctype | Access privileges -----------+----------+----------+-------------+-------------+----------------------- postgres | hironemu | UTF8 | ja_JP.UTF-8 | ja_JP.UTF-8 | ....