Postgresqlでdblinkするメモ

いつから使えるのかわからないけど8.1はいけるっぽい。

dblinkってなに? 他のDBをみれたりするワザっす。多分。。。

基本的な手順は

  • DBを作る
  • dblik.sqlを作ったDBに実行する(関数がいっぱい出来る)

なのだが。

ERROR:  could not establish connection
DETAIL:  could not connect to server: 許可がありません
        Is the server running locally and accepting
        connections on Unix domain socket "/tmp/.s.PGSQL.5432"?

とか

Non-superuser cannot connect if the server does not request a password while using dblink

とか。

色々しらべてまとめ

  • DBをとりあえずpostgresユーザ作る
  • dblik.sqlを作ったDBに実行する(関数がいっぱい出来る)
  • DBは必要なら別のオーナーにする
  • pg_hba.confで、localからのアクセスもpasswordにする(trustにしているとつながらない)
  • postgresは再起動。postgresユーザでpg_ctl で起動する

いやー
めっちゃ謎だった。