• Plugins
  • Created On ,
  • Most Recent By Philip John,

Error establishing a database connection with multisite configuration

Hello

i have a wordpress (3.1.3) configured to be multi-site (www.korben.info). The main website and the network interface is working perfectly. But when i add a new website (subdomains like qa.korben.info), i have an error :

Error establishing a database connection

I don't understand, because, in my wp-config.php, user and password are OK for the database (and the main site is working).

I dont understand where is the problem. Can you help me ? Thank you.

    aecnu

    Greetings Korben00 :-)

    how are you adding sub domains?

    When logged into the site under the main domain that you said works normally - do you go to network admin --> sites --> add new site?

    or are you adding them through a Cpanel?

    Joe :-)

    nelnehal

    check if your wild card subdomain has been set up in cpanel *.yourwebsite.com.

    Korben00
    • 20
    • #5604

    I setup the wildcard correctly in my dns zone (in cpanel-like)
    And i added subdomains via admin-> sites -> add new site

    My configuration is good. I think it's possibly a bug with wordpress ? I remark that when i go to a subdomains/wp-admin, it told me the database need to be repaired. I deactivate all plugins and repair tables, but it change nothing.

    aecnu

    Greetings Korben00 :-)

    next I would check my .htaccess file to see if the following lines are within it:

    # BEGIN WordPress

    RewriteEngine On
    RewriteBase /
    RewriteRule ^index\.php$ - [L]

    # uploaded files
    RewriteRule ^files/(.+) wp-includes/ms-files.php?file=$1 [L]

    RewriteCond %{REQUEST_FILENAME} -f [OR]
    RewriteCond %{REQUEST_FILENAME} -d
    RewriteRule ^ - [L]
    RewriteRule . index.php [L]

    # END WordPress

    and if so the next thing would be to check the httpd.conf file or vhosts.conf file to see if the wildcard actually shows up in the alias's for the specified domain.

    also is this on a shared IP by any chance?

    Joe :-)

    DavidM

    @Korben00, I believe Joe's mention of the htaccess would be the best thing to check from here. Could you let us know how that goes?

    Thanks,
    David

    Philip John

    Hiya!

    Some great advice here, nice one guys!

    I'm pretty sure the problem is that you have WP installed using WWW.

    Basically, as mutli-site depends on wildcard sub-domains it has real issues when you install it on a domain using WWW.

    I.e. instead of having WordPress installed at http://www.korben.info it should be installed at http://korben.info.

    WordPress is going to be looking for http://subsite.www.korben.info instead of http://subsite.korben.info until you can remove WWW.

    We've encountered this loads of times and the short answer is the only fix is to remove WWW.

    Phil

    aecnu

    Greetings Korben00 :-)

    if Phil is correct about this being a WWW problem which I have no doubt that he is ..... In my opinion the easiest way to fix this without reinstalling from the beginning is possibly to go to myPHPadmin or equivalent for your blog and look for the options table ..... open the table and change the setting item #1 "siteurl" to NOT contain the www by simply removing the "www." from the domain name and also item #37 removing the "www." from there also.

    Save the changes and see if it is all resolved :-)

    Joe :-)

    Korben00
    • 20
    • #5604

    Hi,

    i pass my website without www. The main site is working but i have the same problem with subdomains.

    I really don't understand.

    Thank you

    Korben00
    • 20
    • #5604

    here is my htaccess as you asked me :

    SetEnv REGISTER_GLOBALS 0
    SetEnv ZEND_OPTIMIZER 1
    SetEnv MAGIC_QUOTES 0
    SetEnv PHP_VER 5

    # BEGIN WPSuperCache
    <IfModule mod_rewrite.c>
    RewriteEngine On
    RewriteBase /
    AddDefaultCharset UTF-8
    #RewriteCond %{HTTPS} off
    RewriteCond %{HTTP_HOST} ^www\.korben\.info$ [NC]
    RewriteRule ^(.*) http://korben.info/$1 [QSA,L,R=301]
    #RewriteCond %{HTTP_HOST} !^www\.(.*)$ [NC]
    #RewriteRule ^(.*)$ http://www.%{HTTP_HOST}/$1 [R=301,L]
    RewriteCond %{REQUEST_METHOD} !POST
    RewriteCond %{QUERY_STRING} !.*=.*
    RewriteCond %{HTTP:Cookie} !^.*(comment_author_|wordpress_logged_in|wp-postpass_).*$
    RewriteCond %{HTTP:X-Wap-Profile} !^[a-z0-9\"]+ [NC]
    RewriteCond %{HTTP:Profile} !^[a-z0-9\"]+ [NC]
    RewriteCond %{HTTP_USER_AGENT} !^.*(2.0\ MMP|240x320|400X240|AvantGo|BlackBerry|Blazer|Cellphone|Danger|DoCoMo|Elaine/3.$
    RewriteCond %{HTTP_user_agent} !^(w3c\ |w3c-|acs-|alav|alca|amoi|audi|avan|benq|bird|blac|blaz|brew|cell|cldc|cmd-|dang|$
    RewriteCond %{HTTP:Accept-Encoding} gzip
    RewriteCond %{DOCUMENT_ROOT}/wp-content/cache/supercache/%{HTTP_HOST}/$1/index.html.gz -f
    RewriteRule ^(.*) "/wp-content/cache/supercache/%{HTTP_HOST}/$1/index.html.gz" [L]
    RewriteCond %{REQUEST_METHOD} !POST
    RewriteCond %{QUERY_STRING} !.*=.*
    RewriteCond %{HTTP:Cookie} !^.*(comment_author_|wordpress_logged_in|wp-postpass_).*$
    RewriteCond %{HTTP:X-Wap-Profile} !^[a-z0-9\"]+ [NC]
    RewriteCond %{HTTP:Profile} !^[a-z0-9\"]+ [NC]
    RewriteCond %{HTTP_USER_AGENT} !^.*(2.0\ MMP|240x320|400X240|AvantGo|BlackBerry|Blazer|Cellphone|Danger|DoCoMo|Elaine/3.$
    RewriteCond %{HTTP_user_agent} !^(w3c\ |w3c-|acs-|alav|alca|amoi|audi|avan|benq|bird|blac|blaz|brew|cell|cldc|cmd-|dang|$
    RewriteCond %{DOCUMENT_ROOT}/wp-content/cache/supercache/%{HTTP_HOST}/$1/index.html -f
    RewriteRule ^(.*) "/wp-content/cache/supercache/%{HTTP_HOST}/$1/index.html" [L]
    </IfModule>

    # END WPSuperCache

    # BEGIN WordPress
    <IfModule mod_rewrite.c>
    RewriteRule ^index\.php$ - [L]
    # uploaded files
    RewriteRule ^files/(.+) wp-includes/ms-files.php?file=$1 [L]
    RewriteCond %{REQUEST_FILENAME} -f [OR]
    RewriteCond %{REQUEST_FILENAME} -d
    RewriteRule ^ - [L]
    RewriteRule . index.php [L]
    #RewriteCond %{REQUEST_FILENAME} !-f
    #RewriteCond %{REQUEST_FILENAME} !-d
    #RewriteRule . /index.php [L]
    </IfModule>

    # END WordPress

    Barry

    In your sites list in the network admin area of your system - what do the URLs of the sites look like?

    It probably won't do anything, but can you try a htaccess without the supercache rules in? Just so we can rule out any issues with those?

    aecnu

    Greetings Korben00 :-)

    is there any chance that you added the domain to your web server and then deleted it and added it again at anytime?

    Joe :-)

    aecnu

    Greetings Korben00 :-)

    well sir I was referring to the main domain i.e. korben.info if it had been added and deleted and then re-added to your hosting server?

    The reason why I ask this is because if you deleted it from your hosting then re-added it --> it is possible the problem is in the httpd.conf or vhosts.conf

    On occasion I have seen where the removal of a domain from a server does not completely remove the domain, whereas it leaves the domain in the httpd.conf or vhosts.conf depending on the configuration of the server.

    Then when you add the new domain it puts the domain info once again below the original which could very well cause this type of anomaly.

    Therefore if you have root access check these two files looking for korben.info, it will only be or should only be in one of the two conf files, and do two things .....

    First make sure there is only once instance of the domain

    Second make sure in server aliases the entry *.korben.info exists

    After making any changes be sure to restart apache so that the changes will take effect.

    Joe :-)

    Korben00
    • 20
    • #5604

    I'm not sure to understand.

    You recommand me to make a

    a2dissite korben.info
    /etc/init.d/apache restart

    then a2ensite korben.info
    /etc/init.d/apache restart

    Is it correct ? (I have Apache+Nginx)

    And the wildcard in my DNS zone is well configured yes.

    aecnu

    Greetings Korben00 :-)

    no sir that is not what I meant.

    What i am trying to figure out is two things - if there is a duplicate in the httpd.conf file or vhosts.conf file for korben.info that is causing your anomaly and also if there is an entry that says *.korben.info listed under server aliases for korben.info in the entry for the domain that is there.

    I do not know what level of access you have for your server product and if I was your host I would find the problem for you for free ..... lol

    However, if you have root access check the httpd.conf file or vhosts.conf file for your domain - if there is a duplicate - and if in fact there is an entry in server aliases that says *.korben.info

    Joe :-)

    Ovidiu

    The point is you are using nginx. there are quite a few rues to add to make the .htaccess compatible (as far as I remember)...

    besides, using http://web-sniffer.net/ I find out that test.korben.info is giving a 500 server error!

    are you sure you have configured nginx properly for wordpress multisite?

    ###edit###
    corrected text.korben.info to test.korben.info

    aecnu

    Greetings Ovidiu :-)

    what a great new tool you have added to my tools :-) Thanks Ovidiu :-)

    I know nothing about nginx much less about setting it up for Multisite.

    However sir, you made either a typo above in your post in Korben00 test URL or you tested the wrong url, I have no clue which.

    you have text.korben.info vs. test.korben.info

    However in any event it does give server error 500 :-)

    Thanks again for the cool tool :-)

    Joe :-)

    Ovidiu

    @Joe: you're welcome!

    test for korben.info: http://screencast.com/t/ElovQfJz
    test for test.korben.info: http://screencast.com/t/GcRZGAttJLpf

    seriously I am quite shure this is a nginx problem. I tried once, unsuccessfully to run a wp multisite install on nginx, actually I didn't have the patience to sort it out....
    some people shared their nginx rewrite rules, googe helps here... as far as I know, nginx doesn't support .htaccess files... they need to be rewritten so this whole thread is quite pointless if I am right.

    @Korben: under what user does your nginx installation run if it is not nginxuser as you said in your second post here? Do you have the proper rewrite files in place?

    oh and besides the rewrite rules you also need the equivalent of apache's wildcard setup.... kinda make this vhost/nginx install the catch-all of your IP, I hope this was understandable as I don't know the exact terminology...

    ###edit###
    added some possibly useful links:
    - http://wiki.nginx.org/VirtualHostExample
    - http://wordpress.org/support/topic/nginx-php-fpm-php-apc-wordpress-multisite-subdirectory-wp-super-cache?replies=47

    Korben00
    • 20
    • #5604

    Hi all

    thanks for your help ! the right subdomain is test.korben.info (text doesn't exist)
    My nginx is just a reverse proxy that use Apache processes, so i don't have to adapt my htaccess and stuff like that.

    I'm pretty sure the redirection is correct, because, if i enter a subdomain, not created as a multisite, i have an answer (ex : http://hfkerhgtjekrtexxx.korben.info). (so i think subdomain management by nginx and apache is correct)

    And when i create a real subdomain, it answers (why a 500 error, i can't explain) http://test.korben.info that says error with database.

    Here is my nginx conf vhost :

    server {
    listen 80;

    server_name http://www.korben.info korben.info *.korben.info;
    server_name_in_redirect off;
    port_in_redirect off;
    #access_log /var/log/nginx/access.example.com.log;
    gzip on;
    gzip_disable msie6;
    #gzip_static on;
    gzip_comp_level 9;
    gzip_proxied any;
    gzip_types text/plain text/css application/x-javascript text/xml application/xml application/xml+rss text/javascript;
    access_log off;

    location / {
    location ~* ^.+.(jpg|jpeg|gif|css|png|js|ico|txt|srt|swf)$ {
    root /home/korbenblog/www/;
    expires 1d;
    proxy_read_timeout 500;
    proxy_next_upstream error;
    break;
    }

    proxy_pass http://127.0.0.1:81;
    # proxy_pass http://localhost:6081;
    proxy_redirect off;
    proxy_set_header Host $host;
    proxy_set_header X-Real-IP $remote_addr;
    proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;

    client_max_body_size 10m;
    client_body_buffer_size 128k;

    proxy_connect_timeout 90;
    proxy_send_timeout 90;
    proxy_read_timeout 90;

    proxy_buffer_size 4k;
    proxy_buffers 4 32k;
    proxy_busy_buffers_size 64k;
    proxy_temp_file_write_size 64k;
    fastcgi_param REQUEST_METHOD $request_method;

    }
    location ~* ^/wp-content/uploads/(.*)$ {
    rewrite ^/wp-content/uploads(.*)$ http://pictures.korben.info$1 ;
    }

    location ~* ^.+.(jpg|jpeg|gif|css|png|js|ico|txt|srt|swf)$ {
    root /home/korbenblog/www/;
    expires 1d;
    }

    location /nginx_status {
    stub_status on;
    access_log off;
    deny all;
    }

    }

    thank you

    Korben00
    • 20
    • #5604

    Another proof that (i think) it's not a nginx error is that :
    http://test.korben.info/wp-admin/

    It answer, but it tell me the database need to be repaired. I already repaired it and it doesn't change the problem.

    Ovidiu

    you are right. the redirection works if I visit: somethingmadeup.korben.info I am allowed to sign up for that blog.

    I realize you are trying to server static stuff with nginx and proxy everything else back to apache, right?

    I was trying to the the same thing done and hit other problems then yours. I'l dig around and see if I can find my old configs, since they were working, were yours fail but failed somewhere else :-)

    or someone more familiar with nginx speaks up...

    hm, just saw your other reply about the DB.... can you check what the nginx log files are saying? if you have any?

    aecnu

    Greetings :-)

    it looks like to me that it is in the second line: server_name_in_redirect off;

    I seriously know nothing about nginx - but I do know that the sub-domain feature works via wordpress using redirection - but not redirection to a folder.

    Joe :-)

    aecnu

    Greetings :-)

    this is way out of my league concerning nginx - I started checking out Ovidiu's link to the Virtual Host Example and realized that it is so unfamiliar that I bow out of trying to help on this particular subject since I do not plan to learn nginx ..... lol

    Thank you Ovidiu your help and answers are appreciated I am sure and they certainly show me that this is way beyond my scope of knowledge and experience - I therefore bow out gracefully :-)

    Joe :-)

    Ovidiu

    @Joe: I certainly didn't want to scare you away :-) sorry for that. I was trying to help too, and remember I mentioned I gave up on the nginx proxy myself ;-)

    aecnu

    Greetings Ovidiu :-)

    sir you did not scare me away :-)

    But your information, knowledge, and help was much more accurate concerning this issue then mine was from my apache references.

    I think because I am coming from the apache perspective and knowing nothing about nginx it is best that I do not muddle the subject any further :-) That's all ;-)

    Thanks Ovidiu - because I did learn something - I do not want to mess with nginx .... lol .... - and for the link to the new tool in my toolbox :-)

    Joe :-)

    Korben00
    • 20
    • #5604

    All my tables are OK (i ve made mysqlcheck --all-databases)

    :'-(

    Korben00
    • 20
    • #5604

    Hmmm... too much configuration files to edit... I will put the mess in my configuration.

    Korben00
    • 20
    • #5604

    I deactivate all plugins
    i deleted all subdomain (test)

    i upgrade the network
    i recreate the subdomain test.korben.info

    I repair the database and i have these errors :

    The wp_users table is okay.
    The wp_users table is already optimized.

    The wp_usermeta table is okay.
    The wp_usermeta table is already optimized.

    The wp_14_posts table is not okay. It is reporting the following error: Table 'korbenblog.wp_14_posts' doesn't exist. WordPress will attempt to repair this table…
    Failed to repair the wp_14_posts table. Error: Table 'korbenblog.wp_14_posts' doesn't exist

    The wp_14_comments table is not okay. It is reporting the following error: Table 'korbenblog.wp_14_comments' doesn't exist. WordPress will attempt to repair this table…
    Failed to repair the wp_14_comments table. Error: Table 'korbenblog.wp_14_comments' doesn't exist

    The wp_14_links table is not okay. It is reporting the following error: Table 'korbenblog.wp_14_links' doesn't exist. WordPress will attempt to repair this table…
    Failed to repair the wp_14_links table. Error: Table 'korbenblog.wp_14_links' doesn't exist

    The wp_14_options table is not okay. It is reporting the following error: Table 'korbenblog.wp_14_options' doesn't exist. WordPress will attempt to repair this table…
    Failed to repair the wp_14_options table. Error: Table 'korbenblog.wp_14_options' doesn't exist

    The wp_14_postmeta table is not okay. It is reporting the following error: Table 'korbenblog.wp_14_postmeta' doesn't exist. WordPress will attempt to repair this table…
    Failed to repair the wp_14_postmeta table. Error: Table 'korbenblog.wp_14_postmeta' doesn't exist

    The wp_14_terms table is not okay. It is reporting the following error: Table 'korbenblog.wp_14_terms' doesn't exist. WordPress will attempt to repair this table…
    Failed to repair the wp_14_terms table. Error: Table 'korbenblog.wp_14_terms' doesn't exist

    The wp_14_term_taxonomy table is not okay. It is reporting the following error: Table 'korbenblog.wp_14_term_taxonomy' doesn't exist. WordPress will attempt to repair this table…
    Failed to repair the wp_14_term_taxonomy table. Error: Table 'korbenblog.wp_14_term_taxonomy' doesn't exist

    The wp_14_term_relationships table is not okay. It is reporting the following error: Table 'korbenblog.wp_14_term_relationships' doesn't exist. WordPress will attempt to repair this table…
    Failed to repair the wp_14_term_relationships table. Error: Table 'korbenblog.wp_14_term_relationships' doesn't exist

    The wp_14_commentmeta table is not okay. It is reporting the following error: Table 'korbenblog.wp_14_commentmeta' doesn't exist. WordPress will attempt to repair this table…
    Failed to repair the wp_14_commentmeta table. Error: Table 'korbenblog.wp_14_commentmeta' doesn't exist

    The wp_blogs table is okay.

    The wp_signups table is okay.

    The wp_site table is okay.

    The wp_sitemeta table is okay.

    The wp_registration_log table is okay.

    The wp_blog_versions table is okay.

    Philip John

    Have you tried manually creating those tables that don't exist and running the repair again?

    Phil

    Korben00
    • 20
    • #5604

    So i try to create the tables manually (by duplicate the structure of existing tables). The SQL check was OK and WP asked me to deactivate the define('WP_ALLOW_REPAIR', true);

    But i have always the SQL error bug.

    (the new subdomain test is http://toto.korben.info)

    Regards

    Korben00
    • 20
    • #5604

    I also try to duplicate my database to another one and switch it but same result.

    Korben00
    • 20
    • #5604

    Hey guys,

    i succeed !!!

    I delete my wp-config.php and my .htaccess and i reconfigure from scratch and it works !!!

    Thank you again for your patience and your help