I know this was asked back in 2016; just wondering if there was an update. How do you set the database name for a site?
Hi @dkardell - The response to this would still be the same as the one below.
Is there a reason you need to do this locally? If so you could also create a feature request so that others can vote, comment, or follow. That way we can gauge interest in this for future releases.
I’m trying to develop multiple websites that all are installed on the same server.
Are you trying to create a multisite?
No not multi-site. Independent domains on the same server each having their own named DB
Ah okay just making sure. Per the comment above you should be able to change the DB names when you deploy the sites to whatever server they’ll live on. Are you self hosting these?
Yes self hosting these. How would I update the export to use a different DB
This guide should help you to update the DBs once you move the sites.
Thanks… I was wondering if I could update that before importing it on the host. I guess I could always follow this after I deployed as long as I do not have a DB called “local” on my server. I’m just trying to make it cleaner on Export / Import.
so can I just change {“database”:“local”,“user”:“root”,“password”:“root”} in the local-site.json and the config.php to be my database choice and username, password?
So wait… am I over thinking this… when you export form Local and then import, you on a server, you have to import with the DB already set up right? So do these import plugins ignore the DB, USERNAME and PW? I assume the answer is yes. What do these imports do with the wp-config.php?
Hi @dkardell
Thank you for your patience and communication! I’ll try to provide some more insight below here:
- As mentioned, Local doesn’t simply have a way to change the dbname, dbuser, and dbpass from the UI
- WordPress is written in a way that all the DB connection details are in the
wp-config.php
file. This is a file that is usually unique to the environment that each specific WP site (remote, staging, local) is running in. You probably shouldn’t upload this file to the server unless that’s really what you want to do. - If you do need to make changes before uploading the site to the server, you can always unzip the archive, make the changes that need to be made before deploying, and then proceed with deploying in whatever way makes sense for the server.
When using our Local Connect feature to push sites to WP Engine or Flywheel for example, all those deployment details are taken care of for you automatically. When deploying manually, those updates depend entirely on the remote server. Something that might be an option to help do this for you would be using a plugin alternative like WP Migrate PRO.
I would say the plugin WP Migrate Pro is a must for this and it makes the process so much easier to migrate websites and changes to the database prefix and name on the fly.