2

Well I have asked this question in WP Forums, StackOverflow, and GoDaddy community as well, but nothing worked out. Hoping something is in here.

I used 2 separated subdomains for my blog and site (2separate SQL database). But not I cudn't maintain separately so trying to merge them into a single WP driven site. If I do that, I will end up with limitation of max 1GB SQL DB set by GoDaddy (and I can't purchase dedicated solutions for this).

There is a way out to split a single DB into 2, or use more than 1 DB for WP. So, asking for you genius guys to help me out.

2
  • 5
    Use a host that isn't garbage...
    – Wyck
    Commented Jun 16, 2011 at 1:34
  • 1GB is a large database, how many posts / pages have you got?! Commented Jun 16, 2011 at 8:34

2 Answers 2

5

Not 100% sure how your DB could get that big. Have you gone through and cleaned out post revisions, old rows in the wp_options table from old plugins, etc?

2
  • simply because of many posts and drafts, the database is larger.
    – Ekendra
    Commented Jun 16, 2011 at 3:56
  • 1
    that's still very, VERY large. I have a site with over 2700 posts and the database isn't that large. I'd first go and make sure all post revisions are removed.
    – Norcross
    Commented Jun 22, 2011 at 2:37
3

I have a working solution but it could seems a bit hackish. Put this code inside your wp-config.php and have fun! Note: You need to remove other occurences of define('DB_NAME') etc.

switch($_SERVER['HTTP_HOST'])
{
 case 'blog.example.com': 
{
    define('DB_NAME', 'database_1');
    define('DB_USER', 'user_for_db1');
    define('DB_PASSWORD', 'pwd_for_db1');
    define('DB_HOST', 'localhost');
    break;
}
 case 'www.example.com': 
{
    define('DB_NAME', 'database_2');
    define('DB_USER', 'user_for_db2');
    define('DB_PASSWORD', 'pwd_for_db2');
    define('DB_HOST', 'localhost');
    break;
}

The code above checks for $_SERVER['HTTP_HOST'] variable and switch db connection according to it.

Hope this helps!

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.