Forums | Mahara Community

Support /
Problem connecting to Postgresql database


anonymous profile picture
Account deleted
Posts: 5

23 June 2009, 3:11

Hi,

I'm pretty new to Ubuntu and I've never used postgresql before (I usually use mysql) and am having difficulties getting mahara to connect to the database and get the message:

The error received was:
postgres7 error: [-1: Database connection failed] in CONNECT(localhost, 'postgres', '****', mahara)

I'm sure this has something to do with me not correctly setting up a user in the database but can't be sure.

Could someone guide me through setting up a user and password in ubuntu/postgresql so that I can connect to my database in Mahara.

Thanks

 

Nick

anonymous profile picture
Account deleted
Posts: 90

23 June 2009, 3:55

Hi nick,

i supose that you have installed postgres database in your computer. Well and the postgres service is running.
if all before is right check the values in the config.php file
$cfg->dbtype   = 'postgres8';
$cfg->dbhost   = 'localhost';
$cfg->dbport   = null;
$cfg->dbname   = 'the name of the database';
$cfg->dbuser   = 'the user of the database, usually: postgres';
$cfg->dbpass   = 'password';

Regards

anonymous profile picture
Account deleted
Posts: 5

23 June 2009, 5:19

Thanks for the reply. 
Yeah, postgres is installed and running. 
What I have done to setup the database is: 
Logged into postgre from the command line as Administrator (the user created when Ubuntu was installed) by typing:
sudo -u postgres psql postgres
I then changed the password for the user 'postgres' by typing:
\password postgres 
and then entered the password.
I then created a database called 'mahara'
Should I then be able to use these details to connect to the database from Mahara ie.
$cfg->dbtype   = 'postgres8';
$cfg->dbhost   = 'localhost';
$cfg->dbport   = null;
$cfg->dbname   = 'mahara';
$cfg->dbuser   = 'postgres';
$cfg->dbpass   = 'password'; <-- where password is the password I set using \password postgres
The only thing I can think of is that in the instructions it says:
# Run these commands while su'd to the 'postgres' user
# If you need to create a database user:
createuser -SRDP (username)
# Actual database creation
createdb -U (username who will be connecting) -EUTF8 (databasename)
Should I have created a user in ubuntu called 'postgres' and logged in using this username?? 
Thanks 
anonymous profile picture
Account deleted
Posts: 5

25 June 2010, 15:16

I had this same problem.  I was installing mahara on a singler server that is both the web front-end and database back-end.  The solution to my problem was to edit the postgres client authentication file.  Instructions for CentOS 5.5 are:

$ sudo vi /var/lib/pgsql/data/pg_hba.conf

change:

local   all   all                  ident sameuser
# IPv4 local connections:
host    all   all  127.0.0.1/32 ident sameuser

to:

local   all   all                  password sameuser
# IPv4 local connections:
host    all  all   127.0.0.1/32   password sameuser

Detailed description of the authentication method 'ident' and 'password' is at the PostgreSQL pg_hba.conf documentation page.

anonymous profile picture
Account deleted
Posts: 5

23 June 2009, 5:36

I found the problem.

I thought I created a database called mahara in postgres but for some reason it wasn't created. I changed the database name in the config to 'template1' (the pre-existing database in postgre) and Mahara was installed to this database. Not ideal but this is a test server at the moment

So, my question is, why didn't the mahara database get created and how do I create a database in postgre to use for mahara??

Cheers :)

anonymous profile picture
Account deleted
Posts: 1643

23 June 2009, 18:26

Hi - installing into template1 is a bad idea, as that database is used as a template for all future databases you create. So they'll all end up having the Mahara tables in them Wink

If possible, you should have a go at deleting those tables and trying again in a new database.

anonymous profile picture
Account deleted
Posts: 5

23 June 2009, 5:38

Oh, and what's the initial admin login username and password? I wasn't asked to provide one on setup

 

Thanks

Heinz Krettek's profile picture
Posts: 480

23 June 2009, 7:05

Hi Nick,

http://wiki.mahara.org/System_Administrator%27s_Guide/Installing_Mahara

shows a chapter with the informations you need Cool Wink

HTH Heinz

anonymous profile picture
Account deleted
Posts: 3

24 July 2009, 10:46

Hi Everyone

 I am experiencing the same issue.

 

// database connection details
// valid values for dbtype are 'postgres8' and 'mysql5'
$cfg->dbtype   = 'postgres8';
$cfg->dbhost   = 'locahost';
$cfg->dbport   = '5432';
$cfg->dbname   = 'mahara';
$cfg->dbuser   = 'postgres';
$cfg->dbpass   = '';

 I get the following:

 

Mahara: Site unavailable

Mahara could not connect to the application database.

* If you are using Mahara, please wait a minute and try again
* If you are the administrator, please check your database settings and make sure your database is available

The error received was:
postgres7 error: [-1: Database connection failed] in CONNECT(locahost:5432, 'postgres', '****', mahara)
 
I've deleted and recreated the table many times. Can't get past this point. I'm on Mac OS X 10.5.7 running
 
I tried using MAMP, but couldn't get anything with MySQL, using the following settings:
 
// database connection details
// valid values for dbtype are 'postgres8' and 'mysql5'
$cfg->dbtype   = 'mysql5';
$cfg->dbhost   = 'locahost';
$cfg->dbport   = '8889';
$cfg->dbname   = 'mahara';
$cfg->dbuser   = 'root';
$cfg->dbpass   = '';
 
and all i get is:
 

Mahara: Site unavailable

Mahara could not connect to the application database.

* If you are using Mahara, please wait a minute and try again
* If you are the administrator, please check your database settings and make sure your database is available

The error received was:
mysql error: [2005: Unknown MySQL server host 'locahost' (1)] in CONNECT(locahost:8889, 'root', '****', mahara)
 
Othere settings:
 
$cfg->wwwroot = 'http://localhost:8888/mahara';
$cfg->dataroot = '/Users/mike/mahara_dataroot/';  (this has RW permissions for the user and has created sub directories.
 
Pretty frustrated at this point and appreciate any help to get this going :)
 
Thanks
 
Mike
 

 

anonymous profile picture
Account deleted
Posts: 1643

25 July 2009, 0:12

Hi - that suggests that PostgreSQL is not listening on localhost:5432 ("connection failed"). Try commenting out both the dbhost and dbport lines, and see if you get a different message?
16 results