A prefix is a common prefix used for table names in the WordPress database. We will explain the benefits of changing this and how to do so.


What is a WordPress prefix?

In addition to image files and programs, WordPress stores content and configuration data in a database. The database has a box-like structure called a table that holds each piece of data, and a prefix is a common prefix used for each table.

The prefix is usually “wp_” and is defined in wp-config.php as follows.

/**
 * WordPress database table prefix
$table_prefix = 'wp_';

Should I change the prefix?

Before installing WordPress, you can change the prefix by rewriting the prefix definition section of wp-config.php above.

Although it is not usually necessary to change the prefix, there are advantages to changing it for improved security or if you want to have multiple WordPress installations in a single database.

Reasons why changing the prefix improves security

One of the most common WordPress attack methods is SQL injection attacks, which exploit vulnerabilities in plug-ins and other programs.

In a SQL injection attack, the database can be rewritten from the outside, and the instructions for database rewriting are sent by the hacker via the Internet.

In this case, if the prefix is not wp_, which is the default setting, the attack has a higher chance of failure, which is useful for improving security.

Although extremely rare, it is possible to find vulnerabilities in popular plug-ins that allow such SQL injection attacks, so it is useful for improving security by eliminating such possibilities.

Multiple WordPress installations in one database

It is also possible to install multiple WordPress sites in a single database by changing the prefix of the newly installed WordPress site.
Generally, we believe that changing the prefix is more commonly used for this purpose.

How to change the prefix

If you are installing a new WordPress installation, you can change the prefix by rewriting the prefix definition section of wp-config.php and installing WordPress.

Example

$table_prefix = 'wpsecond_';

Change database prefix with plugin if wordpress is already built

The safest way to change the prefix of an already built WordPress is to use a plugin that will also change the table prefix, change the wp-config.php settings, and rewrite all other prefix-related information recorded in the database.

Once you have installed the plugin by searching for “Brozzme DB Prefix & Tools Add-ons” on the add plugin screen, you can change the prefix from Tools > DB PREFIX in the admin screen.

We recommend that you make a database backup before changing the prefix.

We recommend using a security plugin to improve WordPress security.
Free WordPress:Malware Scan & Security Plug-in [Malware and Virus Detection and Removal].