LoginSignup
4
3

More than 5 years have passed since last update.

UbuntuにPostgreSQLをいれる

Posted at

MySQL派なのですが、最近Herokuをよくいじるようになったので、開発環境にPostgreSQLをいれたときの備忘録を書いておきます。

環境

Ubuntu11.10

インストールと設定

apt-get経由でいれました。

$ sudo apt-get install postgresql

普段開発に使っているユーザをpostres内に作成します。

$ sudo su - postgres
$ createuser hirotaka
Shall the new role be a superuser? (y/n) y
$ exit

後々、Railsなどで開発をしやすいように設定を変更しておきます。

下記の設定ファイルを編集します。

/etc/postgresql/9.1/main/pg_hba.conf

以下を編集します。

# "local" is for Unix domain socket connections only
local   all             all                                     peer

peerとなっている箇所をtrustに変更します。

# "local" is for Unix domain socket connections only
local   all             all                                     trust

これはローカルからの接続であれば、認証なしで無条件で接続を許可する設定になります。あくまでも開発環境なのでゆるい設定にしました。

設定を読み直します。

$ sudo /etc/init.d/postgresql reload

psqlで接続して動作を確認します。

4
3
0

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
4
3