CiviCRM Community Forums (archive)

*

News:

Have a question about CiviCRM?
Get it answered quickly at the new
CiviCRM Stack Exchange Q+A site

This forum was archived on 25 November 2017. Learn more.
How to get involved.
What to do if you think you've found a bug.



  • CiviCRM Community Forums (archive) »
  • Old sections (read-only, deprecated) »
  • Support »
  • Installing CiviCRM »
  • Joomla! Installations (Moderator: Deepak Srivastava) »
  • MySQL Database Connect failure - SOLVED
Pages: [1]

Author Topic: MySQL Database Connect failure - SOLVED  (Read 6163 times)

robertsm

  • Guest
MySQL Database Connect failure - SOLVED
April 06, 2008, 08:29:45 am
Well, I've searched and searched, but i don't see an answer for this... 

I installed CiviCRM 2.02 on a fresh install of Joomla 1.0.15. The install went smoothly with no errors.  However, when I try to access CiviCRM through the Joomla Administrator interface I get the following message (note: the server/database configs below are obfuscated, but are correct on my install):

Code: [Select]
Cannot open mysql://DBUser:DBPassword@localhost:/tmp/mysql5.sock/MySite_DBName?new_link=true: DB Error: connect failed
I've also noticed that the notorious "civicrm.settings.php" cannot be found anywhere in the install.

Server:
Host: ICDSoft
PHP: v 5.2.5
MySQL: v 5.0.45
Open basedir: none
Timeout set to 600 through php.ini

Also,
  • I checked the database with PHPMyAdmin and the CiviCRM tables were inserted during the install.
  • I've tried installing using the typical Joomla installation method (my PHP settings are set high enough to allow the larger file upload) and installing from the directory as delineated elsewhere in the documentation.  I get the same results both ways.

So...
  • Is "civicrm.settings.php" supposed to be installed with CiviCRM v2.02? Do I need to manually install and configure this?
  • It appears that CiviCRM is pulling the database config from the Joomla configuration.php, yet it still cannot connect.  Joomla is obviously buzzing along fine with the same settings. Any ideas why? Can I manually change these settings somewhere, and if so where?

Any help, advice or kicks in the head for being a dolt would be appreciated!
Matt
« Last Edit: April 06, 2008, 09:49:51 pm by robertsm »

Donald Lobo

  • Administrator
  • I’m (like) Lobo ;)
  • *****
  • Posts: 15963
  • Karma: 470
    • CiviCRM site
  • CiviCRM version: 4.2+
  • CMS version: Drupal 7, Joomla 2.5+
  • MySQL version: 5.5.x
  • PHP version: 5.4.x
Re: MySQL Database Connect failure
April 06, 2008, 11:50:55 am

1. if its giving u the below error, it has found civicrm.settings.php in the right place :) (administrator/components/com_civicrm/civicrm.settings.php)

2. Your DSN string:

Code: [Select]
mysql://DBUser:DBPassword@localhost:/tmp/mysql5.sock/MySite_DBName?new_link=true


looks a bit wierd to me. Having the mysql socket name in the db name path is just plain wrong. It should be more like:

Code: [Select]
mysql://DBUser:DBPassword@localhost/MySite_DBName?new_link=true

can u check the civicrm.settings.php file and see what the value is there

lobo
A new CiviCRM Q&A resource needs YOUR help to get started. Visit our StackExchange proposed site, sign up and vote on 5 questions

robertsm

  • Guest
Re: MySQL Database Connect failure
April 06, 2008, 12:09:39 pm
hi lobo... thanks for the response!
Quote
can u check the civicrm.settings.php file and see what the value is there
Well, that's the weird part. I can't see/find a civicrm.settings.php anywhere in the install (other than the sample in the templates).

Here are the contents of the administrator/components/com_civicrm/ directory:
   admin.civicrm.php
   Civicrm (Directory)
   civicrm.xml
   configure.php
   install.civicrm.php
   toolbar.civicrm.php
   uninstall.civicrm.php

Side note/More Info: i just confirmed MySQL supports InnoDB.  When i look at the DB using phpMyAdmin, i notice the following message when i click on one of the CiviCRM tables:  ""InnoDB free: 0 kB; (`domain_id`) REFER `MySite_DBName/civicrm_domain`(`id`)"

Again... thank you for the help!
matt


Donald Lobo

  • Administrator
  • I’m (like) Lobo ;)
  • *****
  • Posts: 15963
  • Karma: 470
    • CiviCRM site
  • CiviCRM version: 4.2+
  • CMS version: Drupal 7, Joomla 2.5+
  • MySQL version: 5.5.x
  • PHP version: 5.4.x
Re: MySQL Database Connect failure
April 06, 2008, 01:00:03 pm

ahh, in joomla the settings file is generated on the first civicrm page load. hence there is no settings file there. I'm surprised the schema has loaded.

Can you cut-and-paste the complete error message you receive when you goto a civicrm page

thanx

lobo
A new CiviCRM Q&A resource needs YOUR help to get started. Visit our StackExchange proposed site, sign up and vote on 5 questions

robertsm

  • Guest
Re: MySQL Database Connect failure
April 06, 2008, 01:23:21 pm
It seems i much learning to do!

Here's a screen shot of the error message, with DB name/user/password obscured.

matt

robertsm

  • Guest
Re: MySQL Database Connect failure
April 06, 2008, 01:33:30 pm
Okay, some progress to report...

If i do a remote connect to my DB i can get CiviCRM to load.  I'm thinking that CiviCRM like the following syntax for connecting to MySQL: localhost:/tmp/mysql5.sock

Any thoughts?

matt

Donald Lobo

  • Administrator
  • I’m (like) Lobo ;)
  • *****
  • Posts: 15963
  • Karma: 470
    • CiviCRM site
  • CiviCRM version: 4.2+
  • CMS version: Drupal 7, Joomla 2.5+
  • MySQL version: 5.5.x
  • PHP version: 5.4.x
Re: MySQL Database Connect failure
April 06, 2008, 02:04:34 pm

we construct the dsn from joomla variables using the following piece of code:

Code: [Select]
    $dsn =  'mysql://' .
        $mosConfig_user     . ':' .
        $mosConfig_password . '@' .
        $mosConfig_host     . '/' .
        $mosConfig_db       .
        '?new_link=true';

For some reason, that dsn is not liked by us / PEAR DB library, and hence we cannot connect. i have not seen a dsn like that either. You'll need to investigate and figure out whats happening and why. The code for this is in: configure.php, line 63 and line 125. I'd start by checking the values for mosConfig_host and mosConfig_db and going from there. See my previous post for what PEAR::DB thinks is a good dsn

please report back with how you fixed things.
A new CiviCRM Q&A resource needs YOUR help to get started. Visit our StackExchange proposed site, sign up and vote on 5 questions

robertsm

  • Guest
Re: MySQL Database Connect failure
April 06, 2008, 07:42:24 pm
Well, here's an update:

Rather than hacking the source code right off the bat, i decided to contact my host's tech support (ICDSoft has outstanding/FAST tech support, BTW) to see if there was an alternative connect string that i could use.  Here's their response:
Quote
The installation of this module does not allow for specifying the socket for the connection, and this is why it still tries to connect to MySQL 4. This is a design flaw on the part of the module.

As a workaround, you can connect remotely.

This way, the connection will be established correctly.

Alternatively, the socket can be hard-coded into the application; however, this would require modifying its source code. We can do that for you, if you want, but it is generally not recommended to modify the source code of applications because this may break them.

What is interesting, though, is that after i connected using the remote settings I am now able to switch the Joomla configuration.php DB settings back to localhost, with the socket settings specified, and CiviCRM now/still loads just fine (like it did when connecting remotely).  Is this a first run of CiviCRM issue? I don't know...

I may try modifying the config file as a hard coded/resilient fix.  Will post more info if appropriate.
Thanks again lobo. Any other comments you have would be appreciated!
-Matt

Donald Lobo

  • Administrator
  • I’m (like) Lobo ;)
  • *****
  • Posts: 15963
  • Karma: 470
    • CiviCRM site
  • CiviCRM version: 4.2+
  • CMS version: Drupal 7, Joomla 2.5+
  • MySQL version: 5.5.x
  • PHP version: 5.4.x
Re: MySQL Database Connect failure
April 06, 2008, 08:07:50 pm

I have no idea what you/ICDSoft mean by connecting remotely and then it works by connecting via localhost, so a bit lost there

We use PEAR::DB to manage all database connections. You can check on the DSN formats it accepts here:

http://pear.php.net/reference/DB-latest/DB/DB.html#methodparseDSN

lobo
A new CiviCRM Q&A resource needs YOUR help to get started. Visit our StackExchange proposed site, sign up and vote on 5 questions

robertsm

  • Guest
Re: MySQL Database Connect failure
April 06, 2008, 08:47:54 pm
First off: Dang lobo!  Don't you ever take a break?!  ;)
Quote
I have no idea what you/ICDSoft mean by connecting remotely and then it works by connecting via localhost, so a bit lost there
Well, ICDSoft is a little different in how they have you specify localhost for you DB.  In the config for most scripts, many/most hosts just require you to specify "localhost" - with ICDSoft, however, you need to include the socket as part of that syntax, so "localhost:/tmp/mysql5.sock".

When you specify a remote host, the syntax goes like this: mysql5.abc.sureserver.com:1234 (where 1234 is the port).

Note the difference in the syntax, especially with respect to the "/".  Not sure, but to me it looks like that is the issue. Looking at the DSN formats that you gave the link for (thanks for that, BTW), it appears that having the socket specified like ICDSoft does is not accepted.

So, the cheap solution for this is to keep the connection remote, rather than localhost.  I'd rather keep it local, for speed sake, though (at least i would think localhost would be faster).

Interestingly, there's a posting on this issue (not resolved) in the Drupal install forum as well: http://forum.civicrm.org/index.php/topic,2111.0.html

Will post more after/if i figure out more.
matt

robertsm

  • Guest
Re: MySQL Database Connect failure [SOLUTION]
April 06, 2008, 09:40:02 pm
After discussing this issue with my host it appears that using the hosts remote connection settings are the way to go.  They've told me that my concerns of slower connection using remote connection are unfounded (but they said it much nicer than that), and that the script will still connect locally. 

There is a way to connect to PEAR DB with a socket (http://pear.php.net/manual/en/package.database.db.intro-dsn.php), wherein you change the syntax for localhost/socket to something like this:mysql://user:pass@localhost(/path/to/socket)/DBName  - but when i try that it boinks my Joomla install, so that's a no go.

So, here it is in a nut shell. If your host requires that you specify a socket setting in your host connection syntax (i.e. - something like: "localhost:/tmp/mysql5.sock"), use the hosts remote connection settings instead (i.e. - something like "mysql5.abc.yourhost.com:1234" - with "1234" being the port that your hosts provides).  If you don't know how to connect remotely just contact your host for assistance.

Oh, and this change needs to only be made in the Joomla "configuration.php" file of your root directory (Joomla will still run correctly).  CiviCRM picks up the DB info from that file.  No hacks of CiviCRM are needed with this method.

Thanks again for all of the help lobo!  If i've farked any of this up in the explanation, please let me know!
matt

mcsmom

  • I post frequently
  • ***
  • Posts: 266
  • Karma: 23
    • Official Joomla! Book
  • CiviCRM version: 4 and 3.4
  • CMS version: Joomla!
Re: MySQL Database Connect failure - SOLVED
May 02, 2008, 01:14:11 pm
I'm getting this message

Cannot open : DB Error: not found

After install of the component, but before the creation of the settings file.

Looking at configure.php it looks to me like $dsn is not getting picked up ... does that seem right?


robertsm

  • Guest
Re: MySQL Database Connect failure - SOLVED
May 02, 2008, 01:33:23 pm
mcsmom-

You may want to start a new thread for your question, unless you're having a localhost connection problem like discussed in this thread.
Also, any additional details/information (host, CiviCRM version, etc, etc) that you can provide will help in getting a faster/better response.

-matt

Pages: [1]
  • CiviCRM Community Forums (archive) »
  • Old sections (read-only, deprecated) »
  • Support »
  • Installing CiviCRM »
  • Joomla! Installations (Moderator: Deepak Srivastava) »
  • MySQL Database Connect failure - SOLVED

This forum was archived on 2017-11-26.