Enviado em 24/02/2013 - 01:00h
Segue o passo a passo.
# cat /etc/issue && uname -mrs
# cd /tmp
# wget http://yum.pgrpms.org/9.1/redhat/rhel-6-x86_64/pgdg-redhat91-9.1-5.noarch.rpm
# rpm -Uvh pgdg-redhat91-9.1-5.noarch.rpm
# yum install postgresql91-server
# rpm -qa | grep postgres
# /etc/init.d/postgresql-9.1 start
# /etc/init.d/postgresql-9.1 status
# vi /var/lib/pgsql/9.1/data/pg_hba.conf
* Testando
# psql -h localhost -U postgres -d postgres
Senha para usuário postgres:
# cat /etc/issue && uname -mrs
# yum install php php-pgsql
CentOS release 6.3 (Final)
Kernel \r on an \m
Linux 2.6.32-279.22.1.el6.x86_64 x86_64
# cd /tmp
# wget http://yum.pgrpms.org/9.1/redhat/rhel-6-x86_64/pgdg-redhat91-9.1-5.noarch.rpm
# rpm -Uvh pgdg-redhat91-9.1-5.noarch.rpm
# yum install postgresql91-server
# rpm -qa | grep postgres
postgresql91-server-9.1.8-2PGDG.rhel6.x86_64# /etc/init.d/postgresql-9.1 initdb
postgresql91-9.1.8-2PGDG.rhel6.x86_64
postgresql91-libs-9.1.8-2PGDG.rhel6.x86_64
# /etc/init.d/postgresql-9.1 start
# /etc/init.d/postgresql-9.1 status
(pid 2647) está em execução...# sudo -u postgres psql
* Alterar
psql (9.1.8)
Digite "help" para ajuda.
postgres=# alter user postgres with encrypted password 'teste';
# vi /var/lib/pgsql/9.1/data/pg_hba.conf
# IPv4 local connections:para
host all all 127.0.0.1/32 ident
# IPv6 local connections:
host all all ::1/128 ident
# IPv4 local connections:# /etc/init.d/postgresql-9.1 restart
host all all 127.0.0.1/32 md5
# IPv6 local connections:
host all all ::1/128 md5
* Testando
# psql -h localhost -U postgres -d postgres
Senha para usuário postgres:
psql (9.1.8)# vi db.php
Digite "help" para ajuda.
postgres=#
<?php# php db.php
$conexao = pg_connect("host=localhost port=5432 dbname=postgres user=postgres password=teste") or die ("Não foi possivel conectar ao servidor POSTGRESQL");
//caso a conexão seja efetuada com sucesso, exibe uma mensagem ao usuario
echo "Conexão efetuada com sucesso!!";
?>
Conexão efetuada com sucesso!!