Zen Cart Logo
Forums / Installing on a Linux/Unix Server / Connection to Database failed

Connection to Database failed

Views: 2,958

Results 1 to 16 of 16
13 May 2015, 11:32 AM
#1
royaldave avatar

royaldave

Zen Follower

Join Date:
Aug 2013
Location:
Perth, WA, AU
Posts:
284
Plugin Contributions:
1

Connection to Database failed

Hi

I have my code ready to go and want to update the database to finish everything off.

However when I run zc_install I am getting 'connection to database failed'.

The database details must be correct in configure.php - if I visit the website everything works fine (of course I get the "Your database appears to need patching to a higher level" warning.). Yes I am entering correct Admin login details on screen.

So any ideas? I am stumped.

There is nothing untoward in the log files - it simply says it couldn't connect.

php is 5.4.32 for what its worth.

14 May 2015, 3:48 PM
#2
kobra avatar

kobra

Black Belt

Join Date:
Aug 2005
Location:
Arizona
Posts:
31,500
Plugin Contributions:
4

Re: Connection to Database failed

A link to this??

15 May 2015, 8:25 AM
#3
frank18 avatar

frank18

Deceased

Join Date:
Nov 2007
Location:
Sunny Coast, Australia
Posts:
3,427
Plugin Contributions:
2

Re: Connection to Database failed

Are you able to access your admin?

15 May 2015, 11:43 AM
#4
royaldave avatar

royaldave

Zen Follower

Join Date:
Aug 2013
Location:
Perth, WA, AU
Posts:
284
Plugin Contributions:
1

Re: Connection to Database failed

Yes I can access Admin.

15 May 2015, 12:51 PM
#5
ajeh avatar

ajeh

Oba-san

Join Date:
Sep 2003
Location:
Ohio
Posts:
62,757
Plugin Contributions:
1

Re: Connection to Database failed

Can you compare the files, from your server, for:
/includes/configure.php
/your_secret_admin/includes/configure.php

and ensure that the database settings, password, etc. match beneath the section for:

[B]// define our database connection
[/B]
15 May 2015, 2:01 PM
#6
mc12345678 avatar

mc12345678

Totally Zenned

Join Date:
Jul 2012
Posts:
16,908
Plugin Contributions:
2

Re: Connection to Database failed

royaldave:

Hi

I have my code ready to go and want to update the database to finish everything off.

However when I run zc_install I am getting 'connection to database failed'.

The database details must be correct in configure.php - if I visit the website everything works fine (of course I get the "Your database appears to need patching to a higher level" warning.). Yes I am entering correct Admin login details on screen.

So any ideas? I am stumped.

There is nothing untoward in the log files - it simply says it couldn't connect.

php is 5.4.32 for what its worth.

Confirm that when logged into the admin that when selecting version in the top right corner that ZC is seeing version 5.4.32 as the active PHP version.

In times past, it has been identified that the database upgrade only option is independent of the admin. How has this changed in ZC 1.5.4?

15 May 2015, 2:24 PM
#7
mc12345678 avatar

mc12345678

Totally Zenned

Join Date:
Jul 2012
Posts:
16,908
Plugin Contributions:
2

Re: Connection to Database failed

There also a configure.php file in the includes/local path? If so, what are it's contents? (Obscure DB_PASSWORD information and if included (shouldn't be) any admin or other specifically sensitive information.)

When pasting in the text block, please first select the # symbol in the toolbar above the message block to provide CODE tags around the code.

19 May 2015, 9:30 AM
#8
royaldave avatar

royaldave

Zen Follower

Join Date:
Aug 2013
Location:
Perth, WA, AU
Posts:
284
Plugin Contributions:
1

Re: Connection to Database failed

Sorry for the delay. I discovered I had an issue with my host where changing the php version wasn't working. Turns out it was a problem with my .htaccess file which has now been fixed. I am definately running 5.4.32 - and have also tried 5.5 to get around this issue (didn't work).

Here is my /includes/configure.php

<?php
/**
 * @package Configuration Settings circa 1.5.1
 * @copyright Copyright 2003-2012 Zen Cart Development Team
 * @copyright Portions Copyright 2003 osCommerce
 * @license http://www.zen-cart.com/license/2_0.txt GNU Public License V2.0
 * File Built by zc_install on 2013-09-17 02:05:00
 */


// For Multi Site
include_once('includes/config_sites/sites_switch.php');


/*************** NOTE: This file is similar, but DIFFERENT from the "admin" version of configure.php. ***********/
/***************       The 2 files should be kept separate and not used to overwrite each other.      ***********/



  // Define the webserver and path parameters
  // HTTP_SERVER is your Main webserver: eg-http://www.your_domain.com
  // HTTPS_SERVER is your Secure webserver: eg- https://www.your_domain.com

  define('HTTP_SERVER', 'http://www.funkyballoons.com.au');
  define('HTTPS_SERVER', 'https://www.funkyballoons.com.au');




  // Use secure webserver for checkout procedure?
  define('ENABLE_SSL', 'false');





// NOTE: be sure to leave the trailing '/' at the end of these lines if you make changes!
// * DIR_WS_* = Webserver directories (virtual/URL)
// these paths are relative to top of your webspace ... (ie: under the public_html or httpdocs folder)

  define('DIR_WS_CATALOG', '/zencart154/');
  define('DIR_WS_HTTPS_CATALOG', '/zencart154/');
  define('DIR_WS_IMAGES', 'images/');
  define('DIR_WS_INCLUDES', 'includes/');
  define('DIR_WS_FUNCTIONS', DIR_WS_INCLUDES . 'functions/');
  define('DIR_WS_CLASSES', DIR_WS_INCLUDES . 'classes/');
  define('DIR_WS_MODULES', DIR_WS_INCLUDES . 'modules/');
  define('DIR_WS_LANGUAGES', DIR_WS_INCLUDES . 'languages/');
  define('DIR_WS_DOWNLOAD_PUBLIC', DIR_WS_CATALOG . 'pub/');
  define('DIR_WS_TEMPLATES', DIR_WS_INCLUDES . 'templates/');
  define('DIR_WS_PHPBB', '/');




// * DIR_FS_* = Filesystem directories (local/physical)
//the following path is a COMPLETE path to your Zen Cart files. eg: /var/www/vhost/accountname/public_html/store/

  define('DIR_FS_CATALOG', '/clientdata/n5200-2-static/f/u/funkyballoons.com.au/www/zencart154/');


  //the following path is a COMPLETE path to the /logs/ folder  eg: /var/www/vhost/accountname/public_html/store/logs ... and no trailing slash

  define('DIR_FS_LOGS', '/clientdata/n5200-2-static/f/u/funkyballoons.com.au/www/zencart154/logs');

  define('DIR_FS_DOWNLOAD', DIR_FS_CATALOG . 'download/');
  define('DIR_FS_DOWNLOAD_PUBLIC', DIR_FS_CATALOG . 'pub/');
  define('DIR_WS_UPLOADS', DIR_WS_IMAGES . 'uploads/');
  define('DIR_FS_UPLOADS', DIR_FS_CATALOG . DIR_WS_UPLOADS);
  define('DIR_FS_EMAIL_TEMPLATES', DIR_FS_CATALOG . 'email/');


// define our database connection

  define('DB_TYPE', 'mysql');
  define('DB_PREFIX', '');
  define('DB_CHARSET', 'utf8');
  define('DB_SERVER', 'mysql-2.netregistry.net');
  define('DB_SERVER_USERNAME', 'xxxxxxx');
  define('DB_SERVER_PASSWORD', 'xxxxxx');
  define('DB_DATABASE', 'Zen_Cart_1_3_9h_3_0_funkyballoons_com_au');



  // The next 2 "defines" are for SQL cache support.
  // For SQL_CACHE_METHOD, you can select from:  none, database, or file
  // If you choose "file", then you need to set the DIR_FS_SQL_CACHE to a directory where your apache 
  // or webserver user has write privileges (chmod 666 or 777). We recommend using the "cache" folder inside the Zen Cart folder
  // ie: /path/to/your/webspace/public_html/zen/cache   -- leave no trailing slash  

  define('SQL_CACHE_METHOD', 'database');
  define('DIR_FS_SQL_CACHE', '/clientdata/n5200-2-static/f/u/funkyballoons.com.au/www/zencart154/cache');

// EOF
19 May 2015, 10:43 AM
#9
mc12345678 avatar

mc12345678

Totally Zenned

Join Date:
Jul 2012
Posts:
16,908
Plugin Contributions:
2

Re: Connection to Database failed

What happens if you comment out the multi-site includes line? (Preface with //)

And only long enough to test the upgrade.

19 May 2015, 3:19 PM
#10
kobra avatar

kobra

Black Belt

Join Date:
Aug 2005
Location:
Arizona
Posts:
31,500
Plugin Contributions:
4

Re: Connection to Database failed

I get your site when I navigate to

http: //funkyballoons dot com dot au/zencart154/

No issue connecting to DB

19 May 2015, 9:14 PM
#11
royaldave avatar

royaldave

Zen Follower

Join Date:
Aug 2013
Location:
Perth, WA, AU
Posts:
284
Plugin Contributions:
1

Re: Connection to Database failed

mc12345678:

What happens if you comment out the multi-site includes line? (Preface with //)

And only long enough to test the upgrade.

I tried that already - and have just tried again to be sure. Makes no difference.

19 May 2015, 10:24 PM
#12
mc12345678 avatar

mc12345678

Totally Zenned

Join Date:
Jul 2012
Posts:
16,908
Plugin Contributions:
2

Re: Connection to Database failed

royaldave:

I tried that already - and have just tried again to be sure. Makes no difference.

What about the capitlization used on the database name? I thought I "recently" saw something about the naming convention of DBs, but can not recall if there was a problem with using caps in the name. So one asks, but it works in the store. This doesn't mean that the upgrade process respects it.

The other thought is what other changes have been made to the live store as compared to a vanilla install?

Lastly a "quick fix" to do the upgrade blind to the reason would be to setup a new set of files with the database information pointing to that of the live site and then do the update on that "site"...

20 May 2015, 3:26 AM
#13
royaldave avatar

royaldave

Zen Follower

Join Date:
Aug 2013
Location:
Perth, WA, AU
Posts:
284
Plugin Contributions:
1

Re: Connection to Database failed

mc12345678:

What about the capitlization used on the database name? I thought I "recently" saw something about the naming convention of DBs, but can not recall if there was a problem with using caps in the name. So one asks, but it works in the store. This doesn't mean that the upgrade process respects it.

The other thought is what other changes have been made to the live store as compared to a vanilla install?

Lastly a "quick fix" to do the upgrade blind to the reason would be to setup a new set of files with the database information pointing to that of the live site and then do the update on that "site"...

The caps thing is interesting because apparently on a Windows server its not case-sensitive like linux - don't know why that would be an issue here but you never know...

Is renaming the DB a big deal - do you just rename it in phpadmin then change your config files? I may give it a go.

I have successfully run a database upgrade within my WAMP environment so I can't point the finger at other changes I may have made.

This is where I may be headed. Backup the live DB, import it into my WAMP, run the upgrade there, then drop the live tables and import the data from my 'development area' back into live. I just hate the thought of dropping my live tables - it scares me.

20 May 2015, 11:24 PM
#14
mc12345678 avatar

mc12345678

Totally Zenned

Join Date:
Jul 2012
Posts:
16,908
Plugin Contributions:
2

Re: Connection to Database failed

royaldave:

The caps thing is interesting because apparently on a Windows server its not case-sensitive like linux - don't know why that would be an issue here but you never know...

Is renaming the DB a big deal - do you just rename it in phpadmin then change your config files? I may give it a go.

I have successfully run a database upgrade within my WAMP environment so I can't point the finger at other changes I may have made.

This is where I may be headed. Backup the live DB, import it into my WAMP, run the upgrade there, then drop the live tables and import the data from my 'development area' back into live. I just hate the thought of dropping my live tables - it scares me.

I looked again at the mysql database naming conventions and found that the capitalization is not an issue with unquoted databases. The previous person helped had used a space in their database. Naming convention and thus was having issues.

I have seen another case in the past similar to this one though with different conditions. My suggestion to prevent any issues with passwords would be to do the newsite/upgrade from the existing host and environment. That way there is no dropping of tables.

Backup of course.

22 Jun 2015, 3:24 PM
#15
royaldave avatar

royaldave

Zen Follower

Join Date:
Aug 2013
Location:
Perth, WA, AU
Posts:
284
Plugin Contributions:
1

Re: Connection to Database failed

mc12345678:

I looked again at the mysql database naming conventions and found that the capitalization is not an issue with unquoted databases. The previous person helped had used a space in their database. Naming convention and thus was having issues.

I have seen another case in the past similar to this one though with different conditions. My suggestion to prevent any issues with passwords would be to do the newsite/upgrade from the existing host and environment. That way there is no dropping of tables.

Backup of course.

Thanks to everyone for their suggestions to get me through the problem but I ended up following my own idea which was to copy the live database to my development server, upgrade the database on my development server, drop the tables on the live server, and import the database back into live. Thankfully it all worked without a problem and a small amount of downtime.

Only necessary of course because I could not get the database upgrade to run live.

22 Jun 2015, 3:38 PM
#16
mc12345678 avatar

mc12345678

Totally Zenned

Join Date:
Jul 2012
Posts:
16,908
Plugin Contributions:
2

Re: Connection to Database failed

royaldave:

Thanks to everyone for their suggestions to get me through the problem but I ended up following my own idea which was to copy the live database to my development server, upgrade the database on my development server, drop the tables on the live server, and import the database back into live. Thankfully it all worked without a problem and a small amount of downtime.

Only necessary of course because I could not get the database upgrade to run live.

Been able to login to the admin and as a previously existing customer as well without being told that the password is incorrect? (There are different encryption schemes applied based on the PHP version and if the above worked then thankfully didn't come across a related issue.) Of course may need to make note of the process you used for the next upgrade as it looks like the cause of the problem didn't get fixed but instead worked around.