Tuesday, December 28, 2010

Postgres CentOS

Install PostgreSql Server

Login as the root user and enter the command:
# yum install postgresql postgresql-server

Start Postgresql

Type the following two command:
# chkconfig postgresql on
# service postgresql start

Connect to Postgresql Server

Connect to server using
# su - postgres

Connect using psql command line tool:
$ psql -d template1 -U postgres

Open TCP port 5432

Finally make sure iptables allows remote access to Postgresql database server:
Open /etc/sysconfig/iptables file:
# vi /etc/sysconfig/iptables
Append following line before COMMIT line to open port 5432:

-A RH-Firewall-1-INPUT -m state --state NEW -m tcp -p tcp --dport 5432 -j ACCEPT

Save and close the file. Restart the firewall:
# service iptables restart

wget http://yum.pgsqlrpms.org/reporpms/8.4/pgdg-centos-8.4-2.noarch.rpm
rpm -Uhv pgdg-centos-8.4-2.noarch.rpm
if don't work see url: http://yum.pgsqlrpms.org/reporpms/8.4

Adds
======
#su postgres
psql -d template1 -U postgres (enter the template1 service database)
alter user postgres with password 'postgres_password'; (run query to change the password)
/sbin/service postgresql restart

nmap -P0 -p 5432 192.168.1.2 (if don't have nmap --> #yum install nmap)
Here are the important lines from pg_hba.conf:
Some where you will have a file called postgresql.conf
#listen_addresses = 'localhost' --> '*' and uncomment


References:
[0]http://www.ixavi.com/2010/01/instalar-postgresql-8-3-en-centos-desde-yum/
[1]http://www.cyberciti.biz/tips/postgres-allow-remote-access-tcp-connection.html
[2]http://www.cyberciti.biz/faq/howto-add-postgresql-user-account/
[3]http://www.postgresql.org/docs/7.4/interactive/sql-alteruser.html
[4] http://www.cyberciti.biz/faq/howto-add-postgresql-user-account/

No comments:

Running apps

Runtastic (I uninstalled because force to update your device - Internet connection problems) Runkeeper  (Wrong GPS tracking) Strava   (Curr...