Running PostgreSQL on openSUSE

Last weekend i started setting up a new project. It will be an normal Apache and PHP webbased project with an PostgreSQL database. So i need to set it up.
First of all how do we get. Maybe i should start with the information that i choosed 12.2 (currently Factory) as the version of openSUSE.
While searching on software.opensuse.org i found that there is a database repo.

http://download.opensuse.org/repositories/server:/database:/postgresql/openSUSE_Factory/

Which i added via YaST.

zypper in postgresql postgresql-server

should do the rest. And your database is ready to get configured.
Now switch to the new postgres user.

su - postgres

and initialize the database

initdb -D /var/lib/pgsql/data/

To start the database you need to

pg_ctl -D /var/lib/pgsql/data -l pglog.log start

and your database should be running. Now we need to add our first user and database.

postgres@linux-0ryq:~> createuser -P mytestuser
postgres@linux-0ryq:~> psql
postgres=# CREATE DATABASE mytest;
CREATE DATABASE
postgres=# GRANT ALL ON DATABASE mytest TO mytestuser;
GRANTED

So, this setup should work fo any local connection to the database. If you want to connect from another host you need to adjust your data/pg_hba.conf and add a line like

# TYPE  DATABASE        USER            ADDRESS                 METHOD
host    all             all             all                     trust

or any host you want. If you want to connect from 10.1.0.1 you fust need to set this at address.
Changing the hba conf should force a restart of the database

pg_ctl -D /var/lib/pgsql/data -l pglog.log restart

will do this.
So thats it, more to follow.

This entry was posted in openSUSE. Bookmark the permalink.

Leave a Reply

Your email address will not be published. Required fields are marked *


5 + = twelve

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>