PostgreSQL how to? [resolved]

Basically I'm completely new to PostgreSQL, could you brief me on how to configure, troubleshoot, access it from remote locations and windows machines.

OS: CentOS 6.5 (Red Hat 4.4.7-11)

I am required to use postgresql for Stash software, since MySQL is not really supported by it (while i tried it stated its in wrong format and should be in UTF-8, and i set it so; and even set globally it didn't want to work) so i'm taking next best thing that states its fully supported by Stash software.

I have installed it already, and created user for it.
What next :|. how to deploy database and create user&pass for Stash (software package on same server) to access it.

1 Like

Figured it out,

the configs are located inside
/var/lib/pgsql/data/
had to chown them to postgres.postgre and chmod to 0700

edit pg_hba.conf
add following lines at the end of the file (this is where you add trust, allowing for access]
host all all [IP of your machine or whole subnet] trust

(also add ip of your server same way, fyi found that it doesn't allow localhost, and same in connection string "no localhost" only ip)

save
edit postgresql.conf
find line with listen_addresses = (should be in first 30-50 or so lines)
change to
listen_addresses = '*'
This makes it listen on all IP's localhost and external for your workstation for remote admin etc.

now restart postgresql service
/etc/init.d or service whichever you prefer...

now time to jump to postgresql user and create user and db for it.
su postgres

type-in psql to get inside postgresql cli

First create role (user name + as master admin etc)
CREATE ROLE username WITH LOGIN PASSWORD 'Your pass' VALID UNTIL 'infinity';
CREATE DATABASE db_name WITH ENCODING='UTF8' OWNER=username CONNECTION LIMIT=-1;

boom, test it, it should work.

/q to exit from postgresql cli

Thanks

1 Like