Change table prefix?

Hey guys, is it possible to set our own table prefixes prior to setting up a new site? Thanks!

Not at the moment but you can always set up a new site, change the prefix, then save it as a Blueprint by right-clicking on the site and selecting Save as Blueprint :smiley:

That makes total sense, thanks for the quick response Clay!

@clay huge +1 on adding this as an option when setting up a site.

Really loving Local btw!

1 Like

+1 for a setting for this

+1 for this feature as well.

Please add. Also with ability to choose database name. Maybe have a setting that when selected it will ask you for this info when setting up.

Right now this isn’t in our pipeline simply because it’s something that shouldn’t matter locally. Chances are when you’re pushing the site live the database credentials will be different anyway.

With that said, if someone can give a compelling argument for adding this I’m all ears, but I just don’t think it’s worth adding the complexity to Local :slight_smile:.

+1 for this too.

Great work with local, much appreciated as you know.

The main reason I would like to be able to set the prefix is that, at the moment, I am usually using duplicator to move my sites from local to production.

This process entails the duplicator package writing over any existing tables in the DB with the local tables.

I believe if I set up a Wordpress install and DB on my hosting with my chosen prefix for the tables, the duplicator package will write over these tables with the standard wp_ from my local copy.

Having said all of this, I find myself more questioning the need to change prefixes at all, as a security precaution it seems pretty ineffective. I understand it being necessary for running multiple installs from one DB, but any body who already has access to my db can quite easily run a query to find my prefix out.

I will set up a blueprint as suggested, but may cut this whole process out.

This does matter locally, especially when you are duplicating or deploying to a live site.

No live site should use the default prefix.

When importing a database from a live site and chaining the prefix in Local’s wp-config.php I have ended up with a configuration that reports “Error establishing a database connection”. I can return to the wp-config.php and just change the table prefix back to wp_ and the site returns to the Local default. Note, at this point in time both sets of tables are in the database (I can see them with Sequel Pro, for example). Switching the prefix to my custom value brings back the database error. This error is extremely odd, since clearly the database can be reached.

In any case, if I could create the Local site with my unique table prefix, I bet I would not encounter the database error. It would also simplify set up since I would not have to edit wp-config.php at all.

Please reconsider this feature.

I can’t think of any reason why you’d be getting that error as long as the tables are in the database and the prefix matches what’s in the database.

Are the DB_NAME, DB_USER, and DB_PASSWORD constants set to local, root, and root respectively?

@clay, that error was later traced to using multisite. Turns out you can’t easily change the prefix of a WP multisite installation.

This only make the ability to change the table prefix before the site is set up more critical.

Changing the prefix should be easy. Please add a feature for this.

I often find my self pulling down sites into a local environment, using WP Migrate DB Pro, for example when doing some work for a new client on their existing WordPress site. A lot of the time their table prefix is not the default wp_ and so I have to change it and it just feels messy.

2 Likes