PostgreSQL インストール2011/06/17 |
| データベースサーバーに PostgreSQL をインストールします。 |
|
[root@www ~]#
[root@www ~]# yum -y install postgresql-server /etc/rc.d/init.d/postgresql initdb Initializing database: [ OK ]
[root@www ~]#
vi /var/lib/pgsql/data/postgresql.conf # 59行目:コメント解除して変更 ( 他ホストからのアクセスも受け付ける ) listen_addresses = ' * '
# 334行目:コメント解除して変更 ( ログの形式を [日時 ユーザ DB ~]とする ) log_line_prefix = ' %t %u %d '
/etc/rc.d/init.d/postgresql start Starting postgresql service: [ OK ]
[root@www ~]#
[root@www ~]# chkconfig postgresql on su - postgres # postgres ユーザーに遷移 # 「postgres」ユーザーのDBパスワード設定 -bash-4.1$ psql -c "alter user postgres with password 'password'" ALTER ROLE -bash-4.1$ createuser fermi # DBユーザー「fermi」を作成 Shall the new role be a superuser? (y/n) y # DBの管理者権限を与える -bash-4.1$ su - fermi # Linux 上の「fermi」ユーザーに遷移 Password: [fermi@www ~]$ createdb testdb # テストDB作成 [fermi@www ~]$ psql -l # 確認
List of databases
Name | Owner | Encoding | Collation | Ctype | Access privileg
es
-----------+----------+----------+-------------+-------------+------------------
-----
postgres | postgres | UTF8 | en_US.UTF-8 | en_US.UTF-8 |
template0 | postgres | UTF8 | en_US.UTF-8 | en_US.UTF-8 | =c/postgres : postgres=CTc/postgres
template1 | postgres | UTF8 | en_US.UTF-8 | en_US.UTF-8 | =c/postgres : postgres=CTc/postgres
testdb | fermi | UTF8 | en_US.UTF-8 | en_US.UTF-8 |
(4 rows)
[fermi@www ~]$ psql testdb # テストDBに接続
psql (8.4.7)
Type "help" for help. # パスワード設定 testdb=# alter user fermi with password 'password'; ALTER ROLE # テストテーブル作成 testdb=# create table test ( no int,name text ); CREATE TABLE # テストデータ挿入 testdb=# insert into test (no,name) values (1,'fermi'); INSERT 0 1 # 確認 testdb=# select * from test;
no | name ----+------- 1 | fermi (1 row) # テストテーブル削除 testdb=# drop table test; DROP TABLE # 終了 testdb=# \q dropdb testdb # テストDB削除 |
| Sponsored Link |
|
|