I keep loosing my memory when I get back to PostgreSQL. This post is like a quick note to self on how to do the few very basic things I know how to do in MySQL:
Setup a service with a database accessible from another machine:
yum install mysql-server /usr/bin/mysqladmin -u root password 'new-password' /usr/bin/mysqladmin -u root -h sl63-bare-1 password 'new-password' CREATE USER 'myclient' IDENTIFIED BY 'myclient'; CREATE DATABASE myclientdb; GRANT ALL ON myclientdb.* TO 'myclient';
yum install postgresql-server service postgresql initdb # UNIQUE vim /var/lib/pgsql/data/postgresql.conf # Add: listen_addresses = '*' vim /etc/sysconfig/iptables # Add: -A INPUT -p tcp -m state --state NEW -m tcp --dport 5432 -j ACCEPT vim /var/lib/pgsql/data/pg_hba.conf # Add: host all pgclient 192.168.122.212/32 md5 service postgresql start chkconfig postgresql on su - postgres createuser --pwprompt --echo pgclient createdb --owner pgclient --echo pgclient_db "Test Database for new client"
Config files:
PostgreSQL configuration and data files are held in /var/lib/pgsql/data/. The majority of the service’s configuration lives in postgres.conf while pg_hba.conf contains authentication specifics.
Some Basics:
I was looking these up in documentation first, but then I found this site: http://www.linuxscrew.com/2009/07/03/postgresql-show-tables-show-databases-show-columns/
mysql> SHOW DATABASES pgsql> \l
mysql> SHOW TABLES pgsql> \d
mysql> SHOW COLUMNS <table> pgsql> \d <table>
mysql> DESCRIBE <table> pgsql> \d+ <table>
mysql> USE <database> pgsql> # Does not apply