We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 10940
    • 71 Posts
    Hi, I am moving an existing MODx site from one server to another.
    I imported the database through cpanel + phpmyadmin and I made a backup of the existing home directory in cpanel and uploaded them to the new server too.
    I have changed the database details in content/manager/includes/config.inc.php but I get the following error. It seems MODx is still looking to the old server for the database location. How do I change where MODx looks for the database location?


    PHP error debug
    Error: mysql_connect() [function.mysql-connect]: Access denied for user ’caplush_shopUse’@’localhost’ (using password: YES)
    Error type/ Nr.: Warning - 2
    File: /home/caplush/public_html/content/manager/includes/extenders/dbapi.mysql.class.inc.php
    Line: 85
    Line 85 source: if (!$this->conn = ($persist ? mysql_pconnect($host, $uid, $pwd) : mysql_connect($host, $uid, $pwd))) {

    Parser timing
    MySQL: 0.0000 s s (0 Requests)
    PHP: 0.0282 s s
    Total: 0.0282 s s
      • 21496
      • 225 Posts
      Looks like you’re using an incorrect username/password combination for the mysql database. Did you check in CPanel if the database has an user, and do those settings match the config file?
        René
        • 10940
        • 71 Posts
        Yeah its looking at the wrong url thats why. If I change the config.inc.php back to that accounts mysql db details, it will run perfectly. In fact if I login into the manager and change some text in a document on one account it will also change it on the other - the two sites are looking at the same original url path. I just don’t know how to change the URL path on the new "moved" site cause MODx looks like it generates it automatically in the config.inc.php file.
          • 21496
          • 225 Posts
          I have no url in the config file, so this is a bit confusing.

          Did you change the nameservers so it points to the new server? Or do you access the new server with a different URL? How do you know if you’re looking at the old or the new server? Make sure you have no redirects on the new server using the domain that maybe still points to the old server.
            René
            • 10940
            • 71 Posts
            thanks for your time nightsignals.


            From Line 17 to 31 of config.inc.php, MODx appears to set the URL of the website. This is what I am referring to:

            Line 17 reads: // automatically assign base_path and base_url
            Line 31 reads: $site_url .= $base_url;


            Actually I haven’t been totally accurate too, my apologies.
            I have a reseller webhosting account. So technically there aren’t two different servers involved.
            Instead I have two accounts, both of them using the same server but they are two separate accounts with separate URL’s, i.e. www.mydomain.com/~usernamea and www.mydomain.com/~usernameb. (If you wanted to access the accounts not by their domain names, you can use the usernames of the webhosting account)
              • 10940
              • 71 Posts
              The index.php file in the root directory of MODx also has these settings. I have been playing around with them and can only get errors or the change I make on one account it still effecting the other.

              // set these values here for a small speed increase! smiley
              $database_type = "";
              $database_server = "";
              $database_user = "";
              $database_password = "";
              $dbase = "";
              $table_prefix = "";
              $base_url = "";
              $base_path = "";
                • 10940
                • 71 Posts
                OK I got it sorted out. This is how I did it:

                The password seemed to be one of the reasons it wasnt working. Unlike xCart, I had a problem with having a $ in my MODx database password.

                In the end I edited two files:

                Lines 6 to 11 in the manager/includes/config.inc.php file

                and lines 94 to 102 in the index.php in the root directory.

                All sweet now! Thanks again nightsignals for your time...
                  • 21496
                  • 225 Posts
                  Quote from: global_1981 at Jun 28, 2009, 11:17 PM


                  From Line 17 to 31 of config.inc.php, MODx appears to set the URL of the website. This is what I am referring to:

                  Line 17 reads: // automatically assign base_path and base_url
                  Line 31 reads: $site_url .= $base_url;

                  Good you sorted it out eventually. Just for reference, those url settings are not relevant for accessing the database, they only tell modx where the files are on the server. But there is no need to set them in the config file, or at least I was never in the situation I had to do so. Usually the mysql server is accessed by ’localhost’ as value for $database_server in the config.

                  Here’s a wiki article describing the whole process: http://svn.modxcms.com/docs/display/MODx096/Moving+Site
                    René