Getting PostgreSQL to work in Fedora 8
A very frustrating thing in Fedora 8, is installing PostgreSQL 8 via yum. It all starts in a very nice way:
yum install postgresql postgresql-server and yum install phpPgAdmin if you want a nice web interface to manage your database.
But now what? Where the hell should I look to find further documentation on what these rpm’s just did? Did they create a default database user, what password to use then? It’s not clear at all for the novice user.
Here is how to get it to work…First of all, log in as a normal user (not root!), open a terminal and type su -
Now, we need to initialize the database cluster, this will create some configuration and data files in /var/lib/pgsql:
service postgresql initdb
To be able to use the database via the phpPgAdmin Web interface, we need to change some authentication settings. Edit the configuration file with vim /var/lib/pgsql/data/pg_hba.conf and change all the “ident sameuser” with “md5″ at the end of the file. It should look like this:
# TYPE DATABASE USER CIDR-ADDRESS METHOD
# "local" is for Unix domain socket connections only
local all all md5
# IPv4 local connections:
host all all 127.0.0.1/32 md5
# IPv6 local connections:
host all all ::1/128 md5
It’s time to start the database server and return to our normal user mode:
service postgresql start
logout
Now we can connect to the database to create an user (or role in the PostgreSQL language) and a database. In this example, they both are called “test”.
su - postgres
createdb test
createuser -P test
VoilĂ , now you can use PostgreSQL! You can access it via http://localhost/phpPgAdmin in your browser if you installed the Web interface.
May 15th, 2008 at 12:34 am
Thanks, very useful post
regards,
-eduardo s.m.
June 9th, 2008 at 9:00 am
Wow, I have been looking for this information for ages. I am sure I will post back to forums where I have asked for advices in this matter. However, before doing so, I would be appreciated if I can make it working. I followed the procedures above and was get sticked when I tried to create database and user.
The point I was stuck is :
su - postgres
the computer asking me for a password (I guess for the user postgres). I believe this is a hidden user created during the installation of postgresql as I cannot create the user postgres using the fedora system utility because the user exists. The problem is that - what is the password for user postgres. I did not set it (not during the installation of fedora nor during the installation of postgresql). Is there a default password for it. The second part is how can I change it?
Would be very much appreciated if anyone can advise. Thanks a lot.
Colin CHiang
June 9th, 2008 at 9:40 am
Did you set the login method to md5 in pg_hba.conf and restart the postgresql service?