Forums

$table_prefix ignored (11 posts)

  1. ssinn
    Member
    Posted 1 year ago #

    I am using 2.5.1
    I am installing multiple instances of WordPress using a single database. The first instance (blog.domain.tld) installs correctly. The second instance (blog.domain2.tld) fails to install. blog.domain2.tld refreshes to blog.domain.tld. blog.domain2.tld/wp-admin/install.php advises that WordPress is already installed. It appears to be ignoring the $table_prefix in the wp-config.php file.
    This worked fine in 2.3.3, the last version I tested this on.
    Are there any solutions or workarounds for this?

  2. MichaelH
    moderator
    Posted 1 year ago #

    I know you can have two installs in one database--did it just today.

    Make sure your wp-config.php for each sub-domain has a different $table_prefix.

    Installing_Multiple_Blogs
    Editing wp-config.php

  3. ssinn
    Member
    Posted 1 year ago #

    wp-config.php for domain.tld

    <?php
    define('DB_NAME', 'wordpress');
    define('DB_USER', 'wordpress');
    define('DB_PASSWORD', 'SomePassword');
    define('DB_HOST', 'localhost');

    $table_prefix = 'domain_tld_';

    $server = DB_HOST;
    $loginsql = DB_USER;
    $passsql = DB_PASSWORD;
    $base = DB_NAME;

    define('DB_CHARSET', 'utf8');
    define('DB_COLLATE', '');
    define ('WPLANG', '');
    define('ABSPATH', dirname(__FILE__).'/');
    require_once(ABSPATH.'wp-settings.php');

    ?>

    wp-config.php for domain2.tld

    <?php
    define('DB_NAME', 'wordpress');
    define('DB_USER', 'wordpress');
    define('DB_PASSWORD', 'SomePassword');
    define('DB_HOST', 'localhost');

    $table_prefix = 'domain2_tld_';

    $server = DB_HOST;
    $loginsql = DB_USER;
    $passsql = DB_PASSWORD;
    $base = DB_NAME;

    define('DB_CHARSET', 'utf8');
    define('DB_COLLATE', '');
    define ('WPLANG', '');
    define('ABSPATH', dirname(__FILE__).'/');
    require_once(ABSPATH.'wp-settings.php');

    ?>

    These config files worked fine with 2.3.3. The domain2_tld_ prefixed tables are not being created in the database. It seems the is_blog_installed function in wp-includes/functions.php is involved in this.
    Do these config files look ok?

  4. MichaelH
    moderator
    Posted 1 year ago #

    I'd consider using the wp-config-sample.php as your wp-config.php file in each sub-domain.

    That file is delivered with the WordPress distribution, which is available from the Download tab at the top of this page.

  5. ssinn
    Member
    Posted 1 year ago #

    I just tried that. i used fresh installs of 2.5.1 for domain.tld and domain2.tld. The results are the same. Whichever domain is created first works fine. Whichever comes second is not created.
    So blog.domain.tld works fine. blog.domain2.tld resolves to blog.domain.tld since that is the only database info WordPress can find. blog.domain2.tld/wp-admin/install.php returns the "Already Installed" screen. The domain2_tld_ prefixed tables don't exist in the database.

  6. MichaelH
    moderator
    Posted 1 year ago #

    And you are sure the two different sub-domains are pointed at two entirely different folders?

    Might want to confirm that with your host if necessary.

    [edit]
    Could also put the script described at Finding_Server_Info in one subdomain's root folder and call it testphp1.php and browse to subdomain1.domain.com/testphp1.php then save it as testphp2.php in the 2nd sub-domains root folder and browse to subdomain2.domain.com/testphp2.php.

  7. ssinn
    Member
    Posted 1 year ago #

    The vhost entries are correct for blog.domain.tld and blog.domain2.tld.
    The http_host entries from phpinfo() are correct for blog.domain.tld and blog.domain2.tld
    The phpinfo() for blog.domain2.tld show the document_root as /export/blog.domain.tld/wp when it should show /export/blog.domain2.tld/wp

    I suspect it is pulling this document_root from the database instead of from the vhost entry.
    Is there anything else I can look for in phpinfo() ?

  8. MichaelH
    moderator
    Posted 1 year ago #

    I believe a chat with your host is in order here.

  9. ssinn
    Member
    Posted 1 year ago #

    I am the host.
    It seems like the set_prefix function in wp-db.php is either not getting the value for table_prefix from wp-settings.php. This post sort of describes it but doesn't offer a viable solution. Is this a bug?
    WP Forum post

  10. dd32
    Member
    Posted 1 year ago #

    If I was you, i'd be inserting:
    global $wpdb; echo "<pre>"; var_dump($wpdb); echo "</pre>";
    at the top of the install script(after the requires), Just so you can see the actual table names which its selected.

    I've got multiple installs on a single database, Infact, i just installed 3 to the same database last night, with the prefix's wp_251_1_, wp_251_2_, wp_251_3_

    The only thing i can think of, Is you dont have a . in your prefix do you? That might mess mysql up.

    D

  11. ssinn
    Member
    Posted 1 year ago #

    I entered
    global $wpdb; echo "<pre>"; var_dump($wpdb); echo "</pre>";
    as suggested and ran a clean install. New database, new installation of 2.5.1, new vhost entries, new wp-config.php for blog.domain.tld and blog.domain2.tld.
    The output was identical for both, with WP using the domain_tld_ table_prefix for both installations. The installation for the first domain works. The installation for the second domain fails, as WP ignores the new table_prefix defined in wp-config.php and uses the old table_prefix.

    The table_prefixes are domain_tld_, domain2_tld_ etc.

Topic Closed

This topic has been closed to new replies.

About this Topic

Tags

No tags yet.