| >> HOME >> FC5 MENU >> データベースサーバー (PostgreSQL) |
 |
|
|
|
|
|
|
|
|
|
|
| |
[root@linux ~]# yum -y install postgresql-server
Loading "installonlyn" plugin
Setting up Install Process
Setting up repositories
core [1/3]
core 100% |=========================| 1.1 kB 00:00
updates [2/3]
updates 100% |=========================| 1.2 kB 00:00
extras [3/3]
extras 100% |=========================| 1.1 kB 00:00
Reading repository metadata in from local files
Parsing package install arguments
Resolving Dependencies
--> Populating transaction set with selected packages. Please wait.
---> Downloading header for postgresql-server to pack into transaction set.
postgresql-server-8.1.4-1 100% |=========================| 101 kB 00:00
---> Package postgresql-server.i386 0:8.1.4-1.FC5.1 set to be updated
--> Running transaction check
--> Processing Dependency: postgresql = 8.1.4-1.FC5.1 for package: postgresql-server
--> Restarting Dependency Resolution with new changes.
--> Populating transaction set with selected packages. Please wait.
---> Downloading header for postgresql to pack into transaction set.
postgresql-8.1.4-1.FC5.1. 100% |=========================| 134 kB 00:00
---> Package postgresql.i386 0:8.1.4-1.FC5.1 set to be updated
--> Running transaction check
Dependencies Resolved
=============================================================================
Package Arch Version Repository Size
=============================================================================
Installing:
postgresql-server i386 8.1.4-1.FC5.1 updates 4.0 M
Installing for dependencies:
postgresql i386 8.1.4-1.FC5.1 updates 2.8 M
Transaction Summary
=============================================================================
Install 2 Package(s)
Update 0 Package(s)
Remove 0 Package(s)
Total download size: 6.8 M
Downloading Packages:
(1/2): postgresql-8.1.4-1 100% |=========================| 2.8 MB 00:09
(2/2): postgresql-server- 100% |=========================| 4.0 MB 00:13
Running Transaction Test
Finished Transaction Test
Transaction Test Succeeded
Running Transaction
Installing: postgresql ######################### [1/2]
Installing: postgresql-server ######################### [2/2]
Installed: postgresql-server.i386 0:8.1.4-1.FC5.1
Dependency Installed: postgresql.i386 0:8.1.4-1.FC5.1
Complete!
|
|
|
|
|
|
| |
|
|
| |
[root@linux ~]# service postgresql start
データベースを初期化中: [ OK ]
postgresql サービスを開始中: [ OK ]
|
|
|
| |
|
|
| |
[root@linux ~]# chkconfig postgresql on
[root@linux ~]# chkconfig --list postgresql
postgresql 0:off 1:off 2:on 3:on 4:on 5:on 6:off
|
|
|
|
|
|
| |
|
|
| |
|
|
| |
[root@linux ~]# passwd postgres
Changing password for user postgres.
New UNIX password: xxxxxxxxxxx
Retype new UNIX password: xxxxxxxxxxx
passwd: all authentication tokens updated successfully.
|
|
|
| |
|
|
| |
|
|
| |
[root@linux ~]# su - postgres
-bash-3.1$ psql template1
Welcome to psql 8.1.4, the PostgreSQL interactive terminal.
Type: \copyright for distribution terms
\h for help with SQL commands
\? for help with psql commands
\g or terminate with semicolon to execute query
\q to quit
template1=# alter user postgres with password 'Password';
ALTER ROLE
template1=# \q
-bash-3.1$
|
|
|
|
|
|
| |
|
|
| |
-bash-3.1$ vi /var/lib/pgsql/data/postgresql.conf
#---------------------------------------------------------------------------
# CONNECTIONS AND AUTHENTICATION
#---------------------------------------------------------------------------
# - Connection Settings -
#listen_addresses = 'localhost' # what IP address(es) to listen on;
# comma-separated list of addresses;
# defaults to 'localhost', '*' = all
listen_addresses = '*'
|
|
|
| |
|
|
| |
-bash-3.1$ vi /var/lib/pgsql/data/pg_hba.conf
host all all 192.168.1.11 255.255.255.255 trust
host all all 0.0.0.0 0.0.0.0 password crypt
-bash-3.1$ exit
logout
|
|
|
| |
|
|
| |
[root@linux ~]# service postgresql restart
postgresql サービスを停止中: [ OK ]
postgresql サービスを開始中: [ OK ]
|
|
|
|
|
|
| |
|
|
| |
|
|
| |
|
|
| |
[root@linux ~]# su - postgres
-bash-3.1$ createuser -P fedora
Enter password for new role: xxxxxxxxxx
Enter it again: xxxxxxxxxx
Shall the new role be a superuser? (y/n) n
Shall the new role be allowed to create databases? (y/n) y
Shall the new role be allowed to create more new roles? (y/n) n
CREATE ROLE
-bash-3.1$ exit
logout
|
|
|
| |
|
|
| |
|
|
| |
[root@linux ~]# su - fedora
[fedora@linux ~]$ createdb --encoding EUC_JP testdb
CREATE DATABASE
[fedora@linux ~]$ psql -l
List of databases
Name | Owner | Encoding
-----------+----------+----------
postgres | postgres | EUC_JP
template0 | postgres | EUC_JP
template1 | postgres | EUC_JP
(4 rows)
|
|
|
| |
|
|
| |
|
|
| |
[fedora@linux ~]$ psql testdb
Welcome to psql 8.1.4, the PostgreSQL interactive terminal.
Type: \copyright for distribution terms
\h for help with SQL commands
\? for help with psql commands
\g or terminate with semicolon to execute query
\q to quit
testdb=>
|
|
|
| |
|
|
| |
testdb=> create table testtbl(num int, name varchar(50));
CREATE TABLE
testdb=> \d testtbl
Table "public.testtbl"
Column | Type | Modifiers
--------+-----------------------+-----------
num | integer |
name | character varying(50) |
|
|
|
| |
|
|
| |
testdb=> insert into testtbl values(1,'鈴木 一太郎');
INSERT 0 1
testdb=> select * from testtbl;
num | name
-----+-------------
1 | 鈴木 一太郎
(1 row)
|
|
|
| |
|
|
| |
testdb=> update testtbl set name='鈴木 一之介' where num=1;
UPDATE 1
testdb=> select * from testtbl;
num | name
-----+-------------
1 | 鈴木 一之介
(1 row)
|
|
|
| |
|
|
| |
testdb=> delete from testtbl where num=1;
DELETE 1
testdb=> select * from testtbl;
num | name
-----+------
(0 rows)
|
|
|
| |
|
|
| |
testdb=> drop table testtbl;
DROP TABLE
|
|
|
| |
|
|
| |
testdb=> \q
[fedora@linux ~]$
|
|
|
| |
|
|
| |
[fedora@linux ~]$ dropdb testdb;
DROP DATABASE
[fedora@linux ~]$ exit 
|
|
|
| |
|
|
| |
[root@linux ~]# su - postgres
-bash-3.1$ dropuser fedora
DROP ROLE
-bash-3.1$ exit
logout
|
|
|
 |
|
 |
 |