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.
Is it possible to use two different databases on WordPress depending the environment where
Share
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:
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.