테스트 사이트 - 개발 중인 베타 버전입니다

postgres 설치하기

· 13년 전 · 1015
 테스트: centos5.7
 
1. directory  생성
mkdir -p /usr/local/pgsql
 
2. user 생성
groupadd postgres
useradd -gpostgres -d /usr/local/pgsql postgres
 
3. postgres 다운로드
wget http://wwwmaster.postgresql.org/redir/408/f/source/v9.1.1/postgresql-9.1.1.tar.gz
tar xvzfp postgresql-9.1.1.tar.gz
chown -R postgres.postgres postgresql-9.1.1
 
4. postgres 설치
 
cd postgresql-9.1.1
 
yum -y install bison
flex 2.5.31 이상 필요함.
wget http://sourceforge.net/projects/flex/files/flex/flex-2.5.35/flex-2.5.35.tar.gz/download
tar xvzfp flex-2.5.35.tar.gz
cd flex-2.5.35
./configure;make ;make install
ln -sf /usr/local/bin/flex /usr/bin/flex
yum -y install readline-devel
yum -y install zlib-devel
 
./configure --prefix=/usr/local/pgsql --enable-nls=EUC_KR
make
make install
cd /usr/local/
 
chown -R postgres.postgres pgsql
su -l postgres -c "/usr/local/pgsql/bin/initdb -D /usr/local/pgsql/data"
 
* postgres 시작
/usr/local/pgsql/bin/postgres -D /usr/local/pgsql/data    혹은
/usr/local/pgsql/bin/pg_ctl -D /usr/local/pgsql/data -l logfile start
 
5. 라이브러리 추가
vi /etc/ld.so.conf
/usr/local/pgsql/lib
ldconfig
 
6. postgres 환경변수 설정
su - postgres
vi .bash_profile
----------------------------
PATH=$PATH:/usr/local/pgsql/bin
MANPATH=$MANPATH:/usr/local/pgsql/man
PGLIB=/usr/local/pgsql/lib
PGDATA=/usr/local/pgsql/data
export PATH MANPATH PGLIB PGDATA
----------------------------
source .bash_profile
 
7. postmaster 데몬 띄우기
su - postgres
 /usr/local/pgsql/bin/pg_ctl -D /usr/local/pgsql/data -l logfile start
 
 
 
========================
dump data import하기
psql -e < db.out
 
data export 하기
pg_dumpall -z > db.out
 
db 권한 주기
su - postgres
createuser byoungguk  ---> 권한 주고 싶은 계정
 
db 생성 및 테이블 생성
su - byoungguk
createdb test
psql test
byoungguk=> create table counter ( count int );
byoungguk=> insert into counter values ( 0 );
byoungguk=> \q
 
 
yum -y install php-pgsql
<?
$connect=pg_connect("dbname=test user=byoungguk");
$result=pg_exec($connect,"select * from counter"); 
$count_num = pg_result($result,0,"count");
if (!$count_num) {
    $count_num++;
    pg_exec($connect,"update counter set count=$count_num");
}
echo $count_num;
?>

댓글 작성

댓글을 작성하시려면 로그인이 필요합니다.

로그인하기

게시글 목록

번호 제목
12413
12412
12411
12410
12407
12406
12405
12404
12403
12402
12401
12400
12399
12398
12397
12396
12395
12394
12393
12392
12391
12390
12389
12388
12387