In this short video, we will be showing you how to change your WordPress database prefix.
There are several ways you can go about making the change and we are going to show two simple methods, the first which involves getting your hands dirty by making changes directly to the database using PHPMyAdmin and the second, which is the quickest out of the two – by using a plugin.
Please make sure that before you attempt to make any changes to your database, whether it be manually or by using a plugin, you backup your database.
As mentioned in the video there has been a lot of debates whether you should be changing your database prefix for security reasons, while most web hosting companies recommend that you change your database prefix to avoid being a potential target to spammers and hackers – who could inject your database with malicious scripts – some security experts believe it is a pointless practice and it doesn’t do anything to improve security.
It’s not an argument I will want to take part in any time soon but it will be something we will talk about in one of our upcoming security for WordPress videos.
Now, without further delay, here is a short video showing you how to change your WordPress database prefix using PHPMyAdmin and a simple plugin. The plugin we have chosen to work within this example is the Brozzme DB Prefix & Tools plugin which is very easy to use. It will allow you to change your WordPress database prefix in a matter of clicks.
As mentioned in the video, the following SQL snippet will update your user’s data tables (inc meta data) so that you, as the admin user, do not lose your administrative rights. Without updating the user’s data tables with the new prefix you will have trouble logging in.
All you have to do is simply replace THENEWPREFIX_ with your new prefix and the CURRENTPREFIX_ with your old prefix, whether it be wp_ or any other prefix an auto-installer may have used.
update THENEWPREFIX_usermeta set meta_key = 'THENEWPREFIX_capabilities' where meta_key = 'CURRENTPREFIX_capabilities'; update THENEWPREFIX_usermeta set meta_key = 'THENEWPREFIX_user_level' where meta_key = 'CURRENTPREFIX_user_level'; update THENEWPREFIX_usermeta set meta_key = 'THENEWPREFIX_autosave_draft_ids' where meta_key = 'CURRENTPREFIX_autosave_draft_ids'; update THENEWPREFIX_options set option_name = 'THENEWPREFIX_user_roles' where option_name = 'CURRENTPREFIX_user_roles';
If you have any questions please feel free to comment below.