The forums ran from 2008-2020 and are now closed and viewable here as an archive.

Home Forums Back End A safe way to change the WP db prefix?

  • This topic is empty.
Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
  • #166588

    I am nearly finished building a site. Unfortunately i made a grave mistake while setting it up and forgot to change the wp db prefix beforehand. Now i am a bit worried that changing it afterwards might mess things up “a little bit”. I’ve found a few blog posts about, but each dates back a few month or even years:

    So i am uncertain if that described method is still applicable with wp 3.8.x – “just” to change the wp_ prefix in the table names, within the options table and the usermeta table.

    are there only “wp_” prefixes changed or also “wp” prefixes (from the latter i found a few while browsing the db with phpmyadmin)

    and the prefix itself could be anything with characters and numbers? ( chfvj_ or ch3kjer_ or 37343_ )

    best regards ralf


    Nice to meet you ralf!

    my first question is why do you need to alter the prefix, and cannot use the one currently set?

    if its due to multiple WP why aren’t you using wordpress multi-site?

    If you require altering the database prefix… then you can do this:

    First off… BACKUP that site! TWICE! :)

    steps to complete:
    1. backup
    2. locate the wp-config.php file and alter the following: (alter the prefix here to whatever you like)
    $table_prefix = '?????????';
    3. open your database and add or alter the current prefix to your tables. (all of them)
    4. all done – you may need to restart your webserver and clear any caching plugins you have implemented into wordpress.

    The reason this works is that wordpress is smart. they placed the prefix into the config file so you can easily alter it on the fly at any time. the above procedure does operate properly on all versions of wordpress in v3.

    The reason this works is WP does not place the prefix onto tables during queries… it simple looks at the config file and applies the one you specify onto queries.

    anyhow, hope you have luck with this. it should be easy!


    Thanks for the reply!

    As i wrote at the beginning, i’ve forgot to set a custom wp prefix and so the standard wp_ was set. That would be too much of a risk regarding sql injections. :/

    and regarding your steps, it isn’t necessary anymore to change field names with the old wp_ prefix in the usermeta and options tables like described in the two blog posts? wp is handling that on the fly now after the new prefix is set inside the wp-config file?

    Best regards Ralf


    options and usermeta very well may have additions with the wp_ prefix.

    I woul d search every single table ALL OF THEM just in case that prefix is lingering.

    Make sure you do this to all your plugin tables as well, you never know what someone will do as a programmer if they are unsure how to operate.

    You may wnat to do this in the wordpress plugin folder as well on the files code… just in case some random programmer during plugin install stuck a prefix onto a query.

    just saying, you can never be too careful.

    options table on my WP blog, returned 3… the usermeta returned 95 rows where the key or name started with wp_

    honestly I didn’t believe any of these are connected to the (table) prefix… but perhaps they are? as if you do the search, you see that for instance I have a meta_key with a name of wp_capabillities… there is no table named that… therefore I see no connection. my opinion is that this is a prefix unrelated to the table prefix.. but I could be wrong.

    back it all up and test man!

Viewing 4 posts - 1 through 4 (of 4 total)
  • The forum ‘Back End’ is closed to new topics and replies.