• For a long time, my multi-site WP 3.2.1 setup was humming along nicely with the following $table_prefix setting:

    $table_prefix = 'wp_';

    Last night I had a plugin’s log table get too large and it brought down the MySQL server because of too many connections when I tried to use the plugin’s management pages to empty the log. Once MySQL was running again, I deleted that log table. I still found that I had to regenerate the wp_config.php file to get things working again.

    Upon doing so, I was prompted to repair the database. At first, the repair failed saying that almost all of the multi-site tables didn’t exist. But I could see them plainly at the mysql prompt. Then I noticed that because this was a multisite setup, WP should have been looking for wp_1_posts rather than plain old wp_posts as the repair screen was telling me.

    So, I changed $table_prefix to be ‘wp_1_’ and finished the repair. It saw all the wp_1_ tables. That got my site back up.

    BUT, now I can’t log in. It seems that this workaround caused wp_users to be inaccessible to WordPress. That’s because, obviously, with a $table_prefix setting of ‘wp_1_’ it’s looking for wp_1_users, which it’s never going to find in a multisite setup. It’s supposed to be looking for wp_users as it used to before the site blew up.

    Looking more closely at the settings between my old config file and my new one, I noticed I was missing the allow multisite setting in wp-config.php. Ah! That must be it. So I added define('WP_ALLOW_MULTISITE', true); and changed $table_prefix back to ‘wp_’ like it was before this whole mess began.

    No joy. It went back to “Error establishing database connection”. Rinse, repeat.

    What happened? How do I get back to where it was working as a multi-site again and I could log into the dashboard?

    Here’s my original (obfuscated) wp_config.php file before the log table issue blew everthing up.

    <?php
    /**
     * The base configurations of the WordPress.
     *
     * This file has the following configurations: MySQL settings, Table Prefix,
     * Secret Keys, WordPress Language, and ABSPATH. You can find more information
     * by visiting {@link http://codex.wordpress.org/Editing_wp-config.php Editing
     * wp-config.php} Codex page. You can get the MySQL settings from your web host.
     *
     * This file is used by the wp-config.php creation script during the
     * installation. You don't have to use the web site, you can just copy this file
     * to "wp-config.php" and fill in the values.
     *
     * @package WordPress
     */
    
    // ** MySQL settings - You can get this info from your web host ** //
    /** The name of the database for WordPress */
    define('DB_NAME', 'XXXXXXX');
    
    /** MySQL database username */
    define('DB_USER', 'XXXXXXX');
    
    /** MySQL database password */
    define('DB_PASSWORD', 'XXXXXXX');
    
    /** MySQL hostname */
    define('DB_HOST', 'localhost');
    
    /** Database Charset to use in creating database tables. */
    define('DB_CHARSET', 'utf8');
    
    /** The Database Collate type. Don't change this if in doubt. */
    define('DB_COLLATE', '');
    
    /**#@+
     * Authentication Unique Keys and Salts.
     *
     * Change these to different unique phrases!
     * You can generate these using the {@link https://api.wordpress.org/secret-key/1.1/salt/ WordPress.org secret-key service}
     * You can change these at any point in time to invalidate all existing cookies. This will force all users to have to log in again.
     *
     * @since 2.6.0
     */
    define('AUTH_KEY',         'XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX');
    define('SECURE_AUTH_KEY',  'XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX');
    define('LOGGED_IN_KEY',    'XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX');
    define('NONCE_KEY',        'XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX');
    define('AUTH_SALT',        'XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX');
    define('SECURE_AUTH_SALT', 'XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX');
    define('LOGGED_IN_SALT',   'XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX');
    define('NONCE_SALT',       'XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX');
    
    /**#@-*/
    /*define('WP_ALLOW_REPAIR', true);*/
    /**
     * WordPress Database Table prefix.
     *
     * You can have multiple installations in one database if you give each a unique
     * prefix. Only numbers, letters, and underscores please!
     */
    $table_prefix  = 'wp_';
    
    /**
     * WordPress Localized Language, defaults to English.
     *
     * Change this to localize WordPress. A corresponding MO file for the chosen
     * language must be installed to wp-content/languages. For example, install
     * de_DE.mo to wp-content/languages and set WPLANG to 'de_DE' to enable German
     * language support.
     */
    define('WPLANG', '');
    
    /**
     * For developers: WordPress debugging mode.
     *
     * Change this to true to enable the display of notices during development.
     * It is strongly recommended that plugin and theme developers use WP_DEBUG
     * in their development environments.
     */
    define('WP_DEBUG', false);
    
    /* That's all, stop editing! Happy blogging. */
    
    /** Absolute path to the WordPress directory. */
    if ( !defined('ABSPATH') )
    	define('ABSPATH', dirname(__FILE__) . '/');
    
    /** Sets up WordPress vars and included files. */
    require_once(ABSPATH . 'wp-settings.php');
    //set this to a URL to redirect if a blog does not exist or is a 404 on the main blog. (Useful if signup is disabled)
    // For example, the browser will redirect to http://examples.com/ for the following: define( 'NOBLOGREDIRECT', 'http://example.com/' );
    // define( 'NOBLOGREDIRECT', '' );
    // On a directory based install you can use the 404 handler.
    
    // Location of mu-plugins
    // define( 'WPMU_PLUGIN_DIR', '' );
    // define( 'WPMU_PLUGIN_URL', '' );
    // define( 'MUPLUGINDIR', 'wp-content/mu-plugins' );
    
    // Uncomment to disable the site admin bar
    //define( 'NOADMINBAR', 1 );
    
    define( "WP_USE_MULTIPLE_DB", false );
    define( 'NONCE_SALT', 'XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX' );
    
    /* That's all, stop editing! Happy blogging. */
    
    /** WordPress absolute path to the WordPress directory. */
    if ( !defined('ABSPATH') )
    	define('ABSPATH', dirname(__FILE__) . '/');
    
    /** Sets up WordPress vars and included files. */
    require_once(ABSPATH . 'wp-settings.php');
    ?>

    and here’s the new wp-config.php file as re-generated and then made to look exactly like my old one, except for the $table_prefix setting, and the updated KEYs and SALTs (obfuscated):

    <?php
    /**
     * The base configurations of the WordPress.
     *
     * This file has the following configurations: MySQL settings, Table Prefix,
     * Secret Keys, WordPress Language, and ABSPATH. You can find more information
     * by visiting {@link http://codex.wordpress.org/Editing_wp-config.php Editing
     * wp-config.php} Codex page. You can get the MySQL settings from your web host.
     *
     * This file is used by the wp-config.php creation script during the
     * installation. You don't have to use the web site, you can just copy this file
     * to "wp-config.php" and fill in the values.
     *
     * @package WordPress
     */
    
    // ** MySQL settings - You can get this info from your web host ** //
    /** The name of the database for WordPress */
    define('DB_NAME', 'XXXXXXX');
    
    /** MySQL database username */
    define('DB_USER', 'XXXXXXXX');
    
    /** MySQL database password */
    define('DB_PASSWORD', 'XXXXXXXX');
    
    /** MySQL hostname */
    define('DB_HOST', 'localhost');
    
    /** Database Charset to use in creating database tables. */
    define('DB_CHARSET', 'utf8');
    
    /** The Database Collate type. Don't change this if in doubt. */
    define('DB_COLLATE', '');
    
    /**#@+
     * Authentication Unique Keys and Salts.
     *
     * Change these to different unique phrases!
     * You can generate these using the {@link https://api.wordpress.org/secret-key/1.1/salt/ WordPress.org secret-key service}
     * You can change these at any point in time to invalidate all existing cookies. This will force all users to have to log in again.
     *
     * @since 2.6.0
     */
    define('AUTH_KEY',         'XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX');
    define('SECURE_AUTH_KEY',  'XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX');
    define('LOGGED_IN_KEY',    'XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX');
    define('NONCE_KEY',        'XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX');
    define('AUTH_SALT',        'XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX');
    define('SECURE_AUTH_SALT', 'XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX');
    define('LOGGED_IN_SALT',   'XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX');
    define('NONCE_SALT',       'XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX');
    
    /**#@-*/
    
    /**
     * WordPress Database Table prefix.
     *
     * You can have multiple installations in one database if you give each a unique
     * prefix. Only numbers, letters, and underscores please!
     */
    $table_prefix  = 'wp_1_';
    
    /**
     * WordPress Localized Language, defaults to English.
     *
     * Change this to localize WordPress. A corresponding MO file for the chosen
     * language must be installed to wp-content/languages. For example, install
     * de_DE.mo to wp-content/languages and set WPLANG to 'de_DE' to enable German
     * language support.
     */
    define('WPLANG', '');
    
    /**
     * For developers: WordPress debugging mode.
     *
     * Change this to true to enable the display of notices during development.
     * It is strongly recommended that plugin and theme developers use WP_DEBUG
     * in their development environments.
     */
    define('WP_DEBUG', false);
    
    /* That's all, stop editing! Happy blogging. */
    
    /** Absolute path to the WordPress directory. */
    if ( !defined('ABSPATH') )
    	define('ABSPATH', dirname(__FILE__) . '/');
    
    /** Sets up WordPress vars and included files. */
    require_once(ABSPATH . 'wp-settings.php');
    //set this to a URL to redirect if a blog does not exist or is a 404 on the main blog. (Useful if signup is disabled)
    // For example, the browser will redirect to http://examples.com/ for the following: define( 'NOBLOGREDIRECT', 'http://example.com/' );
    // define( 'NOBLOGREDIRECT', '' );
    // On a directory based install you can use the 404 handler.
    
    // Location of mu-plugins
    // define( 'WPMU_PLUGIN_DIR', '' );
    // define( 'WPMU_PLUGIN_URL', '' );
    // define( 'MUPLUGINDIR', 'wp-content/mu-plugins' );
    
    // Uncomment to disable the site admin bar
    //define( 'NOADMINBAR', 1 );
    
    define( "WP_USE_MULTIPLE_DB", false );
    define( 'NONCE_SALT', 'XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX' );
    
    /* That's all, stop editing! Happy blogging. */
    
    /** WordPress absolute path to the WordPress directory. */
    if ( !defined('ABSPATH') )
    	define('ABSPATH', dirname(__FILE__) . '/');
    
    /** Sets up WordPress vars and included files. */
    require_once(ABSPATH . 'wp-settings.php');
    ?>
Viewing 8 replies - 1 through 8 (of 8 total)
  • Then I noticed that because this was a multisite setup, WP should have been looking for wp_1_posts rather than plain old wp_posts as the repair screen was telling me.

    No, no….

    ordPress only use wp_1_ on the main site when it is an upgraded WordPRess MU install. If you started from 3.0 and enabled multisite, you will mess it up.

    And please stop posting huge chunks of your wp-confgi file. most of it is irrelevant. Use pastebin.

    Moderator Ipstenu (Mika Epstein)

    (@ipstenu)

    πŸ³οΈβ€πŸŒˆ Advisor and Activist

    wp_posts as your MAIN site is actually not incorrect. If you were using WPMU (as in the pre 3.0 merge of MU and regular WP) then you would be correct.

    So question 1: Was this a WP 3.x build or a WPMU 2.x that you upgraded?

    Thread Starter rcwatson

    (@rcwatson)

    Andrea, sorry about that. I honestly didn’t know about pastebin until you mentioned it. Brilliant! wish I’d known about it before. by pasting the entirety, I was trying to show (prove) just how ridiculously similar the wp-config.php files were, but with two entirely different outcomes.

    I honestly don’t remember if I upgraded or installed WP 3.0 merge outright. We (my network admin and I) had to do a number of installs to get to this point (learning curve), so I’d like to think it was a 3.0 setup to begin with. Then again, there might have been a point where we dumped a pre-3.0 database and then imported it into a post-3.0 database. Would that have had a negative effect? (Probably, duh… πŸ™‚ )

    Ipstenu, what I meant was wp_posts, not having a site number designation in its name, is for the “root” blog of this multi-site instance. But the real problem is, how do I make the site see the wp_users table again, but still display posts from wp_1_posts? For a temporary fix, can I rename wp_users to wp_1_users to make it work until I can get a fresh 3.2.1 install to switch over to?

    Moderator Ipstenu (Mika Epstein)

    (@ipstenu)

    πŸ³οΈβ€πŸŒˆ Advisor and Activist

    Ipstenu, what I meant was wp_posts, not having a site number designation in its name, is for the “root” blog of this multi-site instance.

    Which is entirely, 100% correct, don’t screw around with it πŸ˜‰

    If you renamed the databases to wp_1… then you need to UNDO that. It was wrong to do in the first place.

    Then I noticed that because this was a multisite setup, WP should have been looking for wp_1_posts rather than plain old wp_posts as the repair screen was telling me.

    THAT is where you went wrong. it’s SUPPOSED to look for wp_posts

    Also NEVER EVER use a table prefix ending with a number and MultiSite. It’ll make your heart hurt and soul catch on fire.

    Thread Starter rcwatson

    (@rcwatson)

    I didn’t rename the tables to wp_1. WordPress did that for me way back when I set up the first blog in the network. I’m just trying to get back to where wp-config.php recognizes this…back when $table_prefix was, correctly, ‘wp_’.

    Moderator Ipstenu (Mika Epstein)

    (@ipstenu)

    πŸ³οΈβ€πŸŒˆ Advisor and Activist

    So what DID you change?

    If WP created your site with wp_1_… then your prefix is actually wp_ and you were using WPMU (see? This is why I asked earlier – it totally matters).

    In either case, you should leave your prefix ALONE.

    Thread Starter rcwatson

    (@rcwatson)

    Ok, well, that answers that question. Quite literally, I didn’t change a thing in wp-config.php, other than the prefix setting (which should have been fine the way it was) so as to be able to get back to seeing the site again.

    All the more reason to start with a fresh 3.2.1 install, which is what I’m doing now. Thanks for the clarifications.

    Moderator Ipstenu (Mika Epstein)

    (@ipstenu)

    πŸ³οΈβ€πŸŒˆ Advisor and Activist

    Yeah, you fixed the … er wrong thing to get the site back.

    Try running a repair from inside phpmyadmin and NOT WordPress.

Viewing 8 replies - 1 through 8 (of 8 total)
  • The topic ‘table_prefix setting went haywire?’ is closed to new replies.