Database Settings and WP Table Prefix

Hi,

I see Local sets up default database settings (username, password, etc) in the wp-config file, and creates database tables with “wp_” prefix.

I assume its a bad idea to change any of this stuff directly in wp-config, whilst developing my site in Local?

Therefore, what happens when I want to migrate/publish my site to my hosting provider/the live server?

I intend to use All-In-One WP Migration as this seems to be the recommended plugin now days. However, there is no way to edit the database settings before or during the migration?

What’s the best way to do this please?

Thanks
Steve

Just want to shout out Migrate DB Pro – its an amazing plugin for syncing databases (and uploads folders). But it can’t sync when the table prefixes are different. See here for more info: https://deliciousbrains.com/wp-migrate-db-pro/doc/different-table-prefixes/

In general, I’ve always made sure my table prefixes match on local and live. If it’s a brand new site, simple re-create one of the sites to have matching table prefixes. If it’s an existing site, probably will be easier to find a way to change on local than on your webhost. The link above has a recommendation for this Change Table Prefix plugin. I’ve never used it.

1 Like

Hey @Iws!

The prefixes are created when you install Wordpress, if you are migrating, it carries the prefixes where the site goes. Changing it on the wp-config.php will only make Wordpress look for the wrong prefix, to change it for real you need to change the prefixes on the tables in the database and the line on wp-config.

The best and easiest way to migrate a website developed in Local would be indeed to use Duplicator or All-in-One WP Migration. The process of Duplicator is described in the video on the link below:

As for other workflows of migrating your site, you can find it on the Workflow topic:

Thanks for the info, but I’m not sure it helps me.

Local has created the default database settings (username, password, etc) in the wp-config file, and created database tables with “wp_” prefix. That’s fine. But it would have been really cool if I could have enter these details myself, so that when its time to go live, I don’t have any prefix or username and password issues. Obviously I don’t want to leave the database info as default for security reasons.

When I migrate my site with All-In-One WP Migration, the site will be intact, but I need to change the database info, which is the part I need help with?

If I change the database info on the live site, I then cannot upload the remote site again because the database info will not be the same, so I’m guessing its best to change the database info and prefix locally before I publish, is that correct? Or am I completely confused? :wink:

Thanks
Steve

It’s common to be confused with this, is kind of a complex topic if you don’t know the guts of Wordpress and the migration process. I’m gonna try to sum this up for you explaining some of the process behind each migration with each plugin to make you see the difference.

All-in-one WP Migration

  • It creates a single backup file (.wpress) of an existing site
  • To import the backup on the live site you need to already have a Wordpress installation there, and install the plugin in it to be able to import.
  • This means that Wordpress will create the “wp_” prefixes for you when creating the fresh installation, but despite that, the migration process will override this and put the same prefix you have on the local site.

Duplicator

  • It creates a package that you upload directly through FTP to the folder you wish to have the website installed.
  • You don’t need to have a fresh Wordpress installation, the package, along with the “installer.php” file will install the website on the live server just like it is on local.
  • Prefixes will be equal to local’s.

So both options will let you have exactly the same prefixes as local, but bear with me, both options change that in wp-config.php too. You don’t need to worry about anything when migrating through those plugins, they handle everything to you, if something went wrong, there might be a problem at the process of migration or on your server’s configuration.

Keed in mind, your local environment must replicate exactly the same configuration as live site. That’s the best usage for Local, it makes this configuration smoother, as you have a GUI and easy steps to make this.

If you want to change your prefix for security reasons, I present you this post from a known and trusted source of Wordpress security (also, they have a great security plugin):

If even after reading this you still want to change your prefix, yes you must do it locally first, and you can use one of the plugins available for that, looking for “change table prefix”, or you can make it mannually. This approach below to this method can give you some security, but don’t hope to be safe from hackers since there are a number of ways of hijacking Wordpress without proper security on other ends:

I hope I was helpful, if that doesn’t help you with your query, let me know! I’ll be here to help.

Hi atempel,

Thank you ever so much for taking the time to explain the process clearly.

I already use WordFence, which is an excellent plugin, but I was not aware of that article. I’ll leave the prefix as is.

I’m loving Local. its great, very easy to use. However, some of the surrounding processes are a bit confusing.

Thanks again.
Steve

1 Like