Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7517675
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T01:31:38+00:00 2026-05-30T01:31:38+00:00

Is it possible to use two different databases on WordPress depending the environment where

  • 0

Is it possible to use two different databases on WordPress depending the environment where the WordPress is? Like for example on my testing environment it uses a DataBase that is not Localhost eventhough the testing environment is Localhost, and on my deployed environment it uses a different DataBase without me having to change anything? Whenever I finish working on my LocalHost I upload the files through FTP but I need to change the DataBase information everytime.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-30T01:31:39+00:00Added an answer on May 30, 2026 at 1:31 am

    I do a lot of wordpress development (things like themes and plug-ins). I usually install a local copy of wordpress and work off of that. Then once the plug-in or theme is complete, I just export and deploy the specific files to that. There’s no need/reason to move all of the files associated with wordpress (including those carrying database information: wp-config.php).

    However, in a direct answer to your question, I supposed if that’s what you want to do, you could modify the wp-config.php file so that the value of the variables that identify the database depend on your environment. That would be something like this:

    ///////////////////////////////////////
    // Inside wp-config.php
    ///////////////////////////////////////
    
    // Get as fancy as you need to in determining your environment
    if($_SERVER['HTTP_HOST'] == 'localhost') {
        define('DB_NAME', 'my_local_database');
        define('DB_USER', 'root');
        define('DB_PASSWORD', '');
        define('DB_HOST', 'localhost');
    }
    else {
        define('DB_NAME', 'my_other_database');
        define('DB_USER', 'username');
        define('DB_PASSWORD', 'password');
        define('DB_HOST', 'path_to_other_host');
    }
    

    This might not be a good idea, though, because when you update your wordpress that file could be overwritten. Maybe, who knows. But like I said, you’d be better off just moving the files that are specific to your project (like a custom theme or plugin that you work on on your development environment).

    Hope that helps.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Is it possible to use two different databases for the same project in Ruby
I want to use two meta:resourcekey in single control is it possible? for example
I have two different DataContexts (SQL Databases) that have the same data, just with
When I have two mysql servers that have different jobs (holding different databases) but
Is it possible to use Microsoft Entity Framework with Oracle database?
Is it possible to use gcov for coverage testing of multi-threaded applications? I've set
I have an application where I'd like to use a NoSQL database, but I
Is this possible: Joining tables in two databases in one server? 1.1 What connection
Let's say that I've created two different program executables, e.g. in C++. For some
Basically the idea is to use the same hibernate mapping files for two different

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.