We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 10529
    • 73 Posts
    Having a little nightmare ( see http://modxcms.com/forums/index.php/topic,55897.0.html ) and have been trying to sort things out - there is another site I have a similar problem with - so thought I would tackle that prior to the more important client. The error messgae was basically database connection lost - so thought I would do a reinstall - but I forgot to make a copy of the original config.inc.php

    So I copied over install and manager folders and went to install adding the old existing database & username but on testing the database connection - I keep getting connection to host failed - I presume this is becasue I’m attempting to connect to an already configured MODx DB ?

    So is there a work around - should I do a clean install using the same database name etc but having a clean empty database - having exported the old one to my local machine - and try and import the old database once I’ve installed - will that work?

    Or is there another work around - creating a config.inc ??
      • 3749
      • 24,544 Posts
      You should be able to just edit the config.inc.php file and put in the correct values for the DB name, DB user, and DB Password.

      Revolution:
      core/config/config.inc.php

      Evolution:
      manager/includes/config.inc.php

      You may have to manually delete the files in the cache directory, but try without doing that first.

      Then, I would do an upgrade install. If you’re using Evolution, be sure *not* to install the sample site or any snippets or plugins.

        Did I help you? Buy me a beer
        Get my Book: MODX:The Official Guide
        MODX info for everyone: http://bobsguides.com/modx.html
        My MODX Extras
        Bob's Guides is now hosted at A2 MODX Hosting
        • 10529
        • 73 Posts
        Bob

        I did try that by copying another working config file and changing what you suggested but that too failed - however how much should I have copied, all the file or just the first part plus was not sure about this

        $lastInstallTime = 1279791770;

        $site_sessionname = ’SN4c48129a31df4’;

        <?php
        /**
         *    MODx Configuration file
         */
        $database_type = 'mysql';
        $database_server = 'localhost';
        $database_user = 'database user goes here';
        $database_password = 'password goes here';
        $database_connection_charset = 'latin1';
        $database_connection_method = 'SET CHARACTER SET';
        $dbase = '`database name`';
        $table_prefix = 'modx_';
        error_reporting(E_ALL & ~E_NOTICE);
        
        $lastInstallTime = 1279791770;
        
        $site_sessionname = 'SN4c48129a31df4';
        $https_port = '443';
        
        // automatically assign base_path and base_url
        if(empty($base_path)||empty($base_url)||$_REQUEST['base_path']||$_REQUEST['base_url']) {
            $sapi= 'undefined';
            if (!strstr($_SERVER['PHP_SELF'], $_SERVER['SCRIPT_NAME']) && ($sapi= @ php_sapi_name()) == 'cgi') {
                $script_name= $_SERVER['PHP_SELF'];
            } else {
                $script_name= $_SERVER['SCRIPT_NAME'];
            }
            $a= explode("/manager", str_replace("\\", "/", dirname($script_name)));
            if (count($a) > 1)
                array_pop($a);
            $url= implode("manager", $a);
            reset($a);
            $a= explode("manager", str_replace("\\", "/", dirname(__FILE__)));
            if (count($a) > 1)
                array_pop($a);
            $pth= implode("manager", $a);
            unset ($a);
            $base_url= $url . (substr($url, -1) != "/" ? "/" : "");
            $base_path= $pth . (substr($pth, -1) != "/" && substr($pth, -1) != "\\" ? "/" : "");
            // assign site_url
            $site_url= ((isset ($_SERVER['HTTPS']) && strtolower($_SERVER['HTTPS']) == 'on') || $_SERVER['SERVER_PORT'] == $https_port) ? 'https://' : 'http://';
            $site_url .= $_SERVER['HTTP_HOST'];
            if ($_SERVER['SERVER_PORT'] != 80)
                $site_url= str_replace(':' . $_SERVER['SERVER_PORT'], '', $site_url); // remove port from HTTP_HOST Â 
            $site_url .= ($_SERVER['SERVER_PORT'] == 80 || (isset ($_SERVER['HTTPS']) && strtolower($_SERVER['HTTPS']) == 'on') || $_SERVER['SERVER_PORT'] == $https_port) ? '' : ':' . $_SERVER['SERVER_PORT'];
            $site_url .= $base_url;
        }
        
        if (!defined('MODX_BASE_PATH')) define('MODX_BASE_PATH', $base_path);
        if (!defined('MODX_BASE_URL')) define('MODX_BASE_URL', $base_url);
        if (!defined('MODX_SITE_URL')) define('MODX_SITE_URL', $site_url);
        if (!defined('MODX_MANAGER_PATH')) define('MODX_MANAGER_PATH', $base_path.'manager/');
        if (!defined('MODX_MANAGER_URL')) define('MODX_MANAGER_URL', $site_url.'manager/');
        
        // start cms session
        if(!function_exists('startCMSSession')) {
            function startCMSSession(){
                global $site_sessionname;
                session_name($site_sessionname);
                session_start();
                $cookieExpiration= 0;
                if (isset ($_SESSION['mgrValidated']) || isset ($_SESSION['webValidated'])) {
                    $contextKey= isset ($_SESSION['mgrValidated']) ? 'mgr' : 'web';
                    if (isset ($_SESSION['modx.' . $contextKey . '.session.cookie.lifetime']) && is_numeric($_SESSION['modx.' . $contextKey . '.session.cookie.lifetime'])) {
                        $cookieLifetime= intval($_SESSION['modx.' . $contextKey . '.session.cookie.lifetime']);
                    }
                    if ($cookieLifetime) {
                        $cookieExpiration= time() + $cookieLifetime;
                    }
                    if (!isset($_SESSION['modx.session.created.time'])) {
                      $_SESSION['modx.session.created.time'] = time();
                    }
                }


        Thanks for your rapido response!
          • 3749
          • 24,544 Posts
          Is the upgrade install successful?

          How exactly did it fail?

          If you still have the

          Is the other config file from the same version of MODx?

          Which version of MODx are you using?

          Try emptying the cache directory and your browser cache/cookies, then do another upgrade install.

          This should work:

          Do a clean install using the same database name etc but having a clean empty database - having exported the old one to my local machine - and try and import the old database once I’ve installed - will that work?
            Did I help you? Buy me a beer
            Get my Book: MODX:The Official Guide
            MODX info for everyone: http://bobsguides.com/modx.html
            My MODX Extras
            Bob's Guides is now hosted at A2 MODX Hosting