PostgreSQLを入れてみた

Twitter ツイート Hatena Bookmark ブックマーク

MySQLばかり使用しているのですが、とりあえずPostgreSQLも入れてみることにしました。
いろいろとあって、古いバージョンをいれる(8.1.9)
とりあえず、インストールのメモ残しておきます。

PostgreSQL用のユーザーを作成

useradd postgres

#passwd postgres

1
2
3
4
5

ディレクトリを作成、権限を変更
:   ```
# mkdir /usr/local/pgsql
# chown postgres:postgres /usr/local/pgsql
コンパイルする
:   ```

su - postgres

$ ./configure –prefix=/usr/local/pgsql –enable-nls=ja –enable-syslog $ make $ make install

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
    
    環境変数の設定
    :   ```
$ vim ~/.bash_profile

#以下を追加
PGHOME=/usr/local/pgsql
PGDATA=$PGHOME/data
PGLIB=$PGHOME/lib
PATH=$PATH:$HOME/bin:$PGHOME/bin

export PGHOME PGDATA PGLIB PATH
    そして反映させる
    
    ```

source ~/.bash_profile

1
2
3
4
    
    データベースの初期化
    :   ```
initdb --encoding=UTF8 --no-locale --pgdata=/usr/local/pgsql/data
    実はroot権限でやってたから、こんなエラー出て初期化できなかった・・・
    
    ```

Please log in (using, e.g., “su”) as the (unprivileged) user that will own the server process.

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
        
        だから必ずpostgresにしないとだめ。
    
    自動起動用スクリプトの用意
    :   ```
$ cd postgresql-8.1.5/contrib/start-scripts/
$ cp linux /etc/rc.d/init.d/postgres
$ su -
# chkconfig postgres on
```</dl> 
    
    こんなところだと思います。
    
    参考サイト  
    [CentOS4にPostgreSQL8.1.0をインストールする。(2005/12/3)][1]  
    [PostgreSQL8.1.5インストール][2]

 [1]: http://sapporo.cool.ne.jp/maxpower1600/server/linux/postgresql/postgresql8.1.0_install.html
 [2]: http://fclinux.blog101.fc2.com/blog-entry-3.html
comments powered by Disqus
Built with Hugo
テーマ StackJimmy によって設計されています。