Viewing 9 replies - 1 through 9 (of 9 total)
  • First go to cPanel > MySQL and collect this information:

    DB1 name:
    DB1 user:
    DB1 password: (change it if you cannot read it)

    DB2 name:
    DB2 user:
    DB2 password: (change it if you cannot read it)

    Next go to cPanel phpMyAdmin and get this information:

    DB1 table_prefix:
    DB2 table_prefix:
    note: At my own host, I have an extra SQL user assigned to both databases so I can use those credentials to see both databases at once at phpMyAdmin.

    After gathering the above info, open your two wp-config.php files side-by-side and make certain each has what it should from the above.

    If you might be uncertain about each or either site’s URL in the database, edit this and temporarily add it at the top of the respective wp-config.php file/s:

    Select and edit one pair of lines or the other — no trailing slashes — then temporarily place a slash after /*toggle on/off* just above them to un-comment them and make them active.

    /*-either-*/
    /* tell database to recognize and use http://domain.com
    /** @ near top of wp-config.php /*toggle on/off*
    define('WP_HOME','http://domain.com');
    define('WP_SITEURL','http://domain.com');
    /*-or-*/
    /* tell database to recognize and use http://www.domain.com
    /** @ near top of wp-config.php /*toggle on/off*
    define('WP_HOME','http://www.domain.com');
    define('WP_SITEURL','http://www.domain.com');
    /*-end-*/

    If you use the above and still have URL trouble, maybe try this in your active theme’s functions.php:

    Select and edit one pair of lines or the other — no trailing slashes — then temporarily place a slash after /*toggle on/off* just above them to un-comment them and make them active.

    /*-either-*/
    /* tell database to recognize and use http://domain.com
    /** @ near top of theme functions.php /*toggle on/off*
    update_option('siteurl','http://domain.com');
    update_option('home','http://domain.com');
    /*-or-*/
    /* tell database to recognize and use http://www.domain.com
    /** @ near top of theme/functions.php /*toggle on/off*
    update_option('siteurl','http://www.domain.com');
    update_option('home','http://www.domain.com');
    /*-end-*/

    Thread Starter bayworth

    (@bayworth)

    Thank you for this help. I am trying to plough through now. However, I am alrady stuck at your comment about table-prefix.I dont seem to have any such information. should this be a table in the databases. I should have added that I have the woocommerce plugin installed. So my database contains about 19 tables labelled things like Ucomments, Uoptions, Ulinks etc Is the table-prefix data you refer to tucked away in one of these tables or should I be looking elsehwere?

    my database contains about 19 tables labelled things like Ucomments, Uoptions, Ulinks etc

    The table prefix is the part immediately preceding _Ucomments, _Uoptions, _Ulinks, _etc. The WordPress default would look something like this:

    wp_Ucomments
    wp_Uoptions
    wp_Ulinks
    wp_etc

    So, you either have two sets of tables (two “databases”) in one server database (and there is nothing wrong with that as long as each site has its own SQL user) or else you have two databases at the server and with each database having a prefix that might or might not be the same as the other.

    database name + table_prefix + table name =
    DB1name_prefix1_tables
    DB2name_prefix2_tables

    Then as entered in wp-config.php (minus table names):

    define('DB_NAME', 'database_name_here');
    
    define('DB_USER', 'username_here');
    
    define('DB_PASSWORD', 'password_here');
    
    $table_prefix  = 'wp_';
    Thread Starter bayworth

    (@bayworth)

    OK Lee I think I am drifting into choppy waters and might be making things worse. Firstly I have to admit an ID10T error. Yes I was being stupid. When I took your advice and jotted down each database name and user information next to each I realised I had missed a “o” out of the user information and had assumed it was the same as the DB name. Secondly I was loading my modified wp-config file to the wrong folder and hence why my changes were doing nothing. I have since go things round the right way and that seems to have fixed it. Well its working.
    However, following on from you comment I am not sure if I am making things worse and I am still a little confused about the password entry.
    Using my real information now as an example. My original database was labelled db589834258 under this database I had tables all starting with ZctfvVr and then followed by Ucomments etc. So I assume from your comment that the ZctfvVr bit is the table prefix.
    I then have my second database (new) which is called db590009115. However, this seems to contain more tables. It has some tables labelled wNvQHsBcomments, Boptions etc. plus it has a list of tables labelled ZctfvVrUcomments etc. I am assuming the latter tables are were created when I imported the old database and the first ones were created whent he database was first setup. I suppose my question now is, should I have both sets of tables present? Do I need to delete some or am I creating a future problem?
    Finally I have a comment on the password issue in wp-config. I ammended my database password via the phpadmin panel. I then updated the wp-config to reflect the same password and as I said it seems to work fine. But the password is no longer encrypted in the wp-config. Also the password I set on the database does not seem to reflect the password set on the wp-login panel that I access via the website. So it seems there are multiple passwords in use which is all very confusing.

    My original database was labelled db589834258 under this database I had tables all starting with ZctfvVr and then followed by Ucomments etc. So I assume from your comment that the ZctfvVr bit is the table prefix.

    Yes, but I have no idea how the ‘U’ came to be at the beginning of ‘comments’…and please forgive me for not questioning that earlier since that is not how WordPress typically does things.

    my second database…has some tables labelled wNvQHsBcomments, Boptions etc. plus it has a list of tables labelled ZctfvVrUcomments etc.

    Do you have any idea at all about how those table names came to be anything other than ‘_comments’, ‘_options’. _etc? It sounds to me like either you or someone had done some editing outside of phpMyAdmin or else whatever you had used for export/download/upload/import has grossly corrupted things.

    I suppose my question now is, should I have both sets of tables present? Do I need to delete some or am I creating a future problem?

    You can have more than one set of tables (tables for more than one site) in the same database container (database name) at the server, but I do not do that without first having a specific need or reason such as sharing users.

    …the password is no longer encrypted in the wp-config.

    It never was, but it might have appeared to be. Passwords are only encrypted inside the actual database where site user credentials are stored.

    Also the password I set on the database does not seem to reflect the password set on the wp-login panel that I access via the website. So it seems there are multiple passwords in use which is all very confusing.

    Yes, there are different passwords for different things, and they need to be that way as part of overall security:

    Server login at host: hosting username
    Server login at host: hosting password
    note: Some hosts have multiple passwords for doing different things at the server.

    SQL user at server: SQL username (unique for each site)
    SQL user at server: SQL password

    WordPress LogIn: username
    WordPress LogIn: password

    Thread Starter bayworth

    (@bayworth)

    Thanks for this.Regarding the Ucomments query you made. In my first database I just used the Worpress install via my hosting provider (oneandone) so the first set of tables were completely automatically created with U in front. I did install the Woocommerce plugin so maybe its due to this.

    Thread Starter bayworth

    (@bayworth)

    Regarding your comment about database export etc. I used the phpadmin function to export the database. I used the same function to import the old one into the new database.

    the first set of tables were completely automatically created with U in front. I did install the Woocommerce plugin so maybe its due to this.

    Yes, possibly, but I know nothing at all about WooCommerce and now it might deal with a database.

    I used the phpadmin function to export the database. I used the same function to import the old one into the new database.

    Do you have things working now or do you still have troubles?

    Recently 1and1 changed their databases from 5.1 to 5.5 and it has intermittent issues that say there’s an error establishing a connection with the database. Look to see if your database is 5.5. It will say it next to it on the My SQL Databases area of your account.

Viewing 9 replies - 1 through 9 (of 9 total)

The topic ‘Error Establishing Database Connection’ is closed to new replies.