3

I've been trying to install CiviCRM on fresh WordPress 4.7.3 installations on my managed server, but I keep having database connection problems.

When I try to install CiviCRM 4.7.17, the CiviCRM installer can't locate the database or validate any of the database details.

The MySQL server "Does the server exist?" line returns this message: *Can't find the a MySQL server on 'localhost:/tmp/mysql.sock'.: Unknown MySQL server host 'localhost:/tmp/mysql.sock' (2)**

I am using exactly the same database information --MySQL server at localhost:/tmp/mysql.sock/-- that I used to successfully install WordPress.

I've also tried installing CiviCRM 4.6.0 and 4.6.26 on separate fresh installations of WordPress 4.7.3. In both of these attempts, the CiviCRM installer locates the database just fine (using localhost:/tmp/mysql.sock as the MySQL server), and says that the installation has completed successfully after I click "Install."

However, when I click on the CiviCRM tab in both instances, this error appears, and CiviCRM fails to open:

Array ( [callback] => Array ( [0] => CRM_Core_Error [1] => simpleHandler )

[code] => -24
[message] => DB Error: connect failed
[mode] => 16
[debug_info] =>  [nativecode=Can't connect to local MySQL server through socket '/set-in-php.ini' (2)]
[type] => DB_Error
[user_info] =>  [nativecode=Can't connect to local MySQL server through socket '/set-in-php.ini' (2)]
[to_string] => [db_error: message="DB Error: connect failed" code=-24 mode=callback callback=CRM_Core_Error::simpleHandler prefix="" info=" [nativecode=Can't connect to local MySQL server through socket '/set-in-php.ini' (2)]"]

)

I've contacted my managed server's administrators about this, but they think this is CiviCRM-specific problem and haven't been able to help.

We're using PHP 5.6.30. Our other server information is as follows:

Server: Localhost via UNIX socket Server type: MySQL Server version: 5.5.27 - MySQL Community Server (GPL) Protocol version: 10 User: root@localhost

Apache/2.2.32 (Unix) mod_ssl/2.2.32 OpenSSL/1.0.1e-fips PHP/5.6.30 mod_pubcookie/3.3.4a mod_uwa/3.2.1 Database client version: libmysql - 5.5.18 PHP extension: mysqli

This PHP warning pops up in our error logs every time I try to access a CiviCRM installation unsuccessfully:

PHP Warning: mysqli_real_escape_string() expects parameter 1 to be mysqli, boolean given in /data/www/_our____website_/wp-content/plugins/civicrm/civicrm/install/index.php on line 1256

Line 1256 in index.php is: global $installDirPath;

I'm not sure what's causing this problem, and I appreciate any insights you might have.


Per Jon G's note below: the civicrm.settings.php files that are generated in the installation appear to be standard.

The default settings files that are generated return the following database lines:

if (!defined('CIVICRM_UF_DSN')) { define( 'CIVICRM_UF_DSN' , 'mysql://username:password@localhost:/tmp/mysql.sock/civicrm-again?new_link=true'); }

...which look standard. In the past, I've had to manually edit these lines to accommodate the non-standard localhost location (localhost:/tmp/mysql.sock) by inserting tcp( ), like this:

if (!defined('CIVICRM_UF_DSN')) { define( 'CIVICRM_UF_DSN' , 'mysql://username:password@tcp(**localhost:/tmp/mysql.sock)**/civicrm-again?new_link=true'); }

After that --in the past-- CiviCRM worked fine.

Now, neither the default version nor the adjusted tcp() one allows CiviCRM to initialize in my successful 4.6 installations. (I've also tried inputting just "localhost" in place of "localhost:/tmp/mysql.sock" here, but that returns the same error.)

Finally, the MySQL server is running on the standard port, 3306.


Also, I should mention two other things: I installed CiviCRM in 4.6.0 on our server successfully in the past, and this version was working fine till I tried to upgrade to 4.7.17. Since running the upgrade script, clicking on the CiviCRM tab returns an HTTP error 500.

Also, for this and the other 4.6 installations, I adjusted a line in the installation code in modules/civicrm/install/civicrm.php, adding an additional tcp(...) around the server location, per this thread: https://forum.civicrm.org/index.php?topic=12500.0;prev_next=prev#new

The revised line looks like this: $dsn = "mysql://{$config['mysql']['username']}:{$config['mysql']['password']}@tcp({$config['mysql']['server']})/{$config['mysql']['database']}?new_link=true";


UPDATE: I'm still not able to install CiviCRM 4.7.18, but I was able to upgrade my previous database to 4.7.22 by adjusting the civicrm.settings.php file. I got it to work by adding @tcp( ) to civicrm.settings.php (as mentioned above), changing "localhost" to 127.0.0.1, and specifying the port as :3306. The lines I changed were:

define( 'CIVICRM_UF_DSN'; 'mysql://user:password@tcp(127.0.0.1:3306)/database?new_link=true'); define('CIVICRM_DSN', 'mysql://user:password@tcp(127.0.0.1:3306)/database?new_link=true'); define('CIVICRM_DB_CACHE_HOST', '127.0.0.1'); define('CIVICRM_DB_CACHE_PORT', 3306 );

After running the upgrade script again, the upgrade worked!

2

Spent a few hours trying to solve this problem and found the solution to my problem was to add 3306 to the server address. It does say if your server is not using the standard port them to indicated the port. I'm guessing it was trying to use sockets to connect but by using the port address it knows which one to use.

I also found that installing from a zip file worked better than trying a manual install. The only problem was my Php had a file size limit which needed to be increased but apache kept reporting the upload was to big. In the end used a plug in to upload larger files for wordpress upload larger plugins. Now just have a problem with the crm not seeing curl.

  • Hi Barry, you've posted this as an answer, but I'm not sure if you are looking for help yourself. If you that's the case, you should ask this as a new question. – William Mortada Jul 10 '17 at 17:05
1

It sounds like you've got something unusual in your civicrm.settings.php file. Here's what the relevant lines look like for me:

define( 'CIVICRM_UF_DSN'           , 'mysql://nwu:<password>@localhost/nwu_wp?new_link=true' );
define( 'CIVICRM_DSN'          , 'mysql://nwu:<password>@localhost/nwu_wpcivicrm?new_link=true' );

Please check the corresponding lines in your installation. If you're not sure how to fix it, please update your question to include those lines - make sure to redact your password!

  • Bless you for your response! Unfortunately, everything looks standard in the settings files that CiviCRM generates. I've added additional info about this to the question above. Thanks for any ideas you have. – K Schoonmaker Apr 15 '17 at 0:09
  • Oh sweet Jesus. I took another look at your note and saw that the database information is actually defined in two locations... that are really close to each other in the settings files. >__< I only added tcp:() to one of these strings. Adding this in in the other location means that at least one of my 4.6 installs is working now. Still not sure why the 4.7.17 version can't see my MySQL server at "localhost:/tmp/mysql.sock"... and why the 4.7.17 upgrade script returns the white screen of death in my current database... but for now, I'll take it! – K Schoonmaker Apr 15 '17 at 0:31
  • You mentioned that you're running on port 3306 - but everything else says you're using a socket file. Which is it? If you're running on port 3306, what about just using that instead of the socket file? – Jon G - Megaphone Tech Apr 26 '17 at 4:21
  • Hi, in the server description I see in phpMyAdmin, it says "Server: Localhost via UNIX socket." But it also says "Server: localhost:3306" at the top of the screen. My server admins say that I should use the socket location for installations like WP, but also say that the server is running on the standard port, 3306. So, I'm not sure. None of the options --localhost, localhost:3306 or localhost:/tmp/mysql.sock-- make a difference to the 4.7.17 CiviCRM installer, which can't locate the database using any of them. – K Schoonmaker Apr 28 '17 at 20:47

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.