Support » Networking WordPress » Tables not created -Error establishing a database connection

  • Resolved suzyloonam



    I have a new WP 4.2 install set up in a sub-directory of the root, hosted on HostGator.

    I installed it manually (several times now). There are no plugins activated. The template is the default. The main install works fine.

    The sub-directory Multi-site Network installation seems to go okay, but then I get an ‘Error establishing a database connection’ when I attempt to load new sites in my browser.

    I get this error because the tables are missing, not because it cannot connect to the DB. I know this because I copied the tables from another multisite installation, and the network site worked properly. But, if I just follow the steps to create a new site, the necessary tables are not created. (User has all privileges).

    These are the lines I added to my wp_config file ( is not my real domain)

    define( ‘WP_ALLOW_MULTISITE’, true );
    define(‘MULTISITE’, true);
    define(‘SUBDOMAIN_INSTALL’, false);
    define(‘DOMAIN_CURRENT_SITE’, ‘’);
    define(‘PATH_CURRENT_SITE’, ‘/’);
    define(‘SITE_ID_CURRENT_SITE’, 1);
    define(‘BLOG_ID_CURRENT_SITE’, 1); `

    This is the entire content of my htaccess file:

    # BEGIN WordPress
    RewriteEngine On
    RewriteBase /
    RewriteRule ^index\.php$ - [L]
    # add a trailing slash to /wp-admin
    RewriteRule ^([_0-9a-zA-Z-]+/)?wp-admin$ $1wp-admin/ [R=301,L]
    RewriteCond %{REQUEST_FILENAME} -f [OR]
    RewriteCond %{REQUEST_FILENAME} -d
    RewriteRule ^ - [L]
    RewriteRule ^([_0-9a-zA-Z-]+/)?(wp-(content|admin|includes).*) $2 [L]
    RewriteRule ^([_0-9a-zA-Z-]+/)?(.*\.php)$ $2 [L]
    RewriteRule . index.php [L]
    # END WordPress

    So, can anyone guess why I’m having this problem? I am at wit’s end.

    Thanks so much.

Viewing 13 replies - 1 through 13 (of 13 total)
  • Hi,

    did you consider to create a CNAME record at your maindomain to allow WP creating multiple subdomains? You can do so via DNS Zone editor within the cpanel of your hostingprovider.

    If you didn’t so do the following:

    1. Create a subdomain like this: *
    2. Go the the / advanced zone editor and check if a new record like in the screenshot was created: Create a record

    -> If not, create one your self.

    You will have to wait up to 24 hours in order to see the changes.

    Thanks ReenPf –

    I’m not using (or hadn’t planned to use) a sub-domain installation, so don’t need a wildcard CNAME record, do I?

    This is a sub-directory multi-site install, because it is not in the root.

    What else could it be?

    That’s correct, you won’t need it on sub-directories.

    Please answer me these questions:

    1. Did you try a fresh installation with an empty database?
    2. What tables are you trying to import?
    3. What exactly is it that you want to do with them?
    4. What’s the prodedure you’ve follwoed when importing that tables into the DB

    1. Did you try a fresh installation with an empty database?

    yes. Many times.

    2. What tables are you trying to import?

    Not trying to import tables. Trying to figure out why my multi-sites install fails to create the tables it needs to run?

    I imported some missing tables from another multi-site DB, to see what would happen if I replaced the tables that were missing. Sure enough, that worked, but I don’t want to have to be uploading tables every time I add a new site.

    Those DBs were deleted, and re-created.

    3. What exactly is it that you want to do with them?
    4. What’s the prodedure you’ve follwoed when importing that tables into the DB

    Again, I’m good with tables, except there is a problem with my multisite install — it is not creating tables it needs to run.

    Following the steps to create multi-sites, i am able to create multi-sites, but they do not load, because they do not connect to the DB, because the tables and data that are supposed to be created when you create a new site are not being created.


    Had the same problem just this moment.

    My solution: Found in the servers error log:

    “WordPress-Datenbank-Fehler COLLATION ‘utf8_general_ci’ is not valid for CHARACTER SET ‘utf8mb4’ f\xc3\xbcr Abfrage CREATE TABLE wp_8_terms (\n term_id….”

    I chanced in the wp_config.php the character set to utf8:
    define(‘DB_CHARSET’, ‘utf8’);

    Now it works fine! I hope this helps you also!

    Thank you, but my character set was already utf8.

    I completely dumped my former install.

    Went back to my first try on a WP site installed in the root. Now I can create new sites but they have no CSS, and I get a redirect loop error when trying to load the new sites wp-admin.

    I know… new issue… needs a new post, or I need to find the thread that already exists.

    Thanks for your patience.

    can you exactly list up what is happening?

    In addition, if you haven’t done yet, delete your browser cache.
    Then got back to your site, hit ctrl + r to dump all date from
    the previously loaded site and reload the page.

    On Mac i think it’s apple + r

    Also try logging in withanother browser.

    Thank you, but I gave up on multi-sites.

    I’m going to build out the site, and maybe I will just dupe it so that every site has its own database, or perhaps I will revisit multi sites at a later date.

    Adapt and overcome!

    And onward! Through the fog. Thank you all for your help.

    Hi, boerni-erlangen and others,

    I got the same:
    – fresh server apache 2.2.22, php 5.4.39, mysql 5.5.43
    – new database created with utf8mb4-unicode-ci
    – fresh WP 4.2 install, update to 4.2.1 makes no change
    – enabled multisite

    everything seems OK
    first site running
    2nd, 3rd etc site can be created without(!) an error shown on screen
    – new tables _2_, _3_ are NOT created
    – errorlog shows each time “WordPress-Datenbank-Fehler COLLATION ‘utf8_general_ci’ is not valid for CHARACTER SET ‘utf8mb4’ f\xc3\xbcr Abfrage CREATE TABLE wp_8_terms “
    The (quick&dirty) fix from boerni is a workaround: define(‘DB_CHARSET’, ‘utf8’);
    – calling new site shows “Error establishing a database connection” (wp_debug NOT showing more info)

    There must be 2 small errors in multisite/database code:
    – no error is shown while creating new website in the multisite environment: error only in apache-error.log
    – the collate is set to utf8_… instead of utf8mb4_…

    should I use utf8 instead (like boerni)?
    how could I fix it to use utf8mb4 ?

    Having the same issue…
    My wp-config is on ‘utf8’, though it’s not working.

    Same problem here.
    I’m starting to think there might be a problem with wordpress 4.2
    I’m going to try installing an older version and see how it goes.

    I think they changes to utf8mb4 in 4.2 … and there might be something forgotten in the multisite code.

    I didn’t want to go back, so I changed my wp-config.php to

    /** Der Datenbankzeichensatz der beim Erstellen der Datenbanktabellen verwendet werden soll */
    define('DB_CHARSET', 'utf8mb4');
    /** Der collate type sollte nicht geƤndert werden */
    define('DB_COLLATE', 'utf8mb4_unicode_ci');

    and my multisite runs.

    Changed the uft8mb4 in uft8 in the wp-config and worked like a charm right away!
    You don’t even know how much time I lost on this!

Viewing 13 replies - 1 through 13 (of 13 total)
  • The topic ‘Tables not created -Error establishing a database connection’ is closed to new replies.