LoginSignup
10
10

More than 5 years have passed since last update.

さくらVPSにPostgreSQLをインストール

Last updated at Posted at 2014-01-26

おかしいとこもあるだろうけど自分用のメモとして。

リポジトリを追加

$ wget -P /tmp http://yum.postgresql.org/9.3/redhat/rhel-6-x86_64/pgdg-centos93-9.3-1.noarch.rpm
$ sudo rpm -ivh /tmp/pgdg-centos93-9.3-1.noarch.rpm

PostgreSQL9.3をインストール

$ sudo yum install -y postgresql93-server.x86_64 postgresql93-devel.x86_64 postgresql93-contrib.x86_64

初期設定

  • DBの初期化
$ sudo /etc/rc.d/init.d/postgresql-9.3 initdb
データベースを初期化中:                                    [  OK  ]
  • 設定ファイルを修正
$ sudo vim /var/lib/pgsql/9.3/data/postgresql.conf

で設定ファイルを開いて

  • 他のホストからのアクセスを可能にする
listen_address = '*'
  • ログの出力形式変更(日付 ユーザ DB)
log_line_prefix = '%t %u %d'
  • PostgreSQLの起動
$ sudo /etc/rc.d/init.d/postgresql-9.3 start
postgresql-9.3 サービスを開始中:                           [  OK  ]
  • 自動起動設定
sudo chkconfig postgresql-9.3 on
  • パスワードの設定
$ su
# passwd postgres
ユーザー postgres のパスワードを変更。
新しいパスワード:
新しいパスワードを再入力してください:
passwd: 全ての認証トークンが正しく更新できました。
  • ユーザの作成
$ sudo su - postgres
$ psql
# create user [ユーザ名]
# alter role [ユーザ名] with createdb;
  • DBの作成
$ createdb [DB名] -U [ユーザ名]
10
10
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
10
10