How To Change The WordPress Database Prefix

When WordPress installs your website, by default it will create the database tables with a prefix of wp_ such as wp_posts, wp_options, wp_users etc. The following article will show you how you can change the table prefix in WordPress.

There are a few reasons why you would want to change the default prefix, the main ones being:

  • Security
  • Multiple WordPress installs on a single database

The most important reason is security. If someone knows the name of your database tables they can preform sql injection in your website which can change or delete the tables on your website. If you keep them as default the hacker could guess that it's still wp_ and use that to their advantage.

If you change the database prefix to something random like 3745jp_ then this is a lot harder for hackers to guess.

Another good reason why you will need to change the database prefix is if you have multiple WordPress installs using the same database. It's worth noting that this is not WordPress multisite this is different WordPress instances using the same server then they will need different table prefixes so that they don't use each others data.

To change the table prefix you need to add a variable in the wp-config file of $table_prefix.

$table_prefix = '3745jp_';

WordPress will now pick this up when making queries and will search for tables that are prefixed with this value. If you haven't changed your tables then WordPress will not be able to find your table and won't know that WordPress has installed, therefore will show you the default install page /wp-admin/install.php.

To find out more variables you can add to the wp-config.php file to change your WordPress install, try out our wp-config Generator.

wp-config Generator

Coveloping Membership

Access to a range of developer tools, get your first month free

Start Your Free Trial

Don't miss out!

Sign up to our newsletter for the latest news from Coveloping

Leave a Reply

Your email address will not be published. Required fields are marked *

Code Copied!