Table of contents
Get the industry’s fastest WordPress hosting◦ 99.999% uptime
◦ Comprehensive security
◦ 24/7 support

WordPress GuideDatabase → Prefix

How to change the WordPress database prefix

For WordPress, the default database prefix, specifically referred to as the database table prefix is wp_, but we recommend changing it to increase the security of your overall WordPress database setup.

The reason for this recommended change is that all your user login details are stored in your database, making your WordPress tables very popular targets for hackers.

Changing the database table prefix makes it harder for malicious database-focused attacks to succeed. The table prefix change will make the site more secure, hardening it to database-based attacks.

Get fast, reliable hosting for WordPress

Power your site with the industry’s fastest, most optimized WordPress hosting

About changing the database prefix

In the simplest terms, changing the database prefix as discussed in this article will help fortify your overall application security.

The reason is that the user access details are stored in the database, making your WordPress application an easier target.

Altering the default database table prefix will be an unexpected twist for the hackers attempting to gain access.

Your default WordPress database table prefix can be changed in a straightforward manner, and this article will help you accomplish this end.

Steps for changing the default WordPress database setup

1. Change the table prefix in wp-config.php

Regarding necessary changes to the wp-config.php file, let’s review the details involved. Those are covered below.

Access the wp-config.php file for your website over FTP or SSH.

Locate the wp-config.php file and open the file in editing mode.

Locate the following entry within the wp-config.php file, which starts out with the default WordPress database table prefix:

Replace wp_ with something else. In this example below, we have replaced it with the cmj_ character string:

Save the changes in the wp-config.php file.

2. Change the table prefix in the database

The free tool, phpMyAdmin, is a database utility that allows the management of MySQL or MariaDB databases. Using phpMyAdmin, any activities like creation or modification of databases, running of queries, and user account management tasks are handled easily — even for a non-techie person.

The phpMyAdmin interface can be accessed through SiteWorx (non-cloud) or your Nexcess Client Portal. Therefore, how you access phpMyAdmin depends on the type of Nexcess plan that you have. Because we have provided the phpMyAdmin as a management tool, Nexcess makes efficient to manage your databases from the Nexcess Client Portal.

Access the tool phpMyAdmin and select the respective database for the application.

Click on the database name in the menu to the left to unfold all tables.

Select all tables that start with the wp_ character string. You should have 12 table selected in total.

With those tables selected, open the dropdown menu and select Replace Table Prefix. Replace the table prefix as needed.

Type in wp_ in the From field, and the new database table prefix in the To field, which will be cmj_ in our example.

Click Continue to make the change.

3. Change all references to include the new database table prefix

To complete the table prefix change, you will need to replace old table prefix with the new table prefix in the settings that are stored in your database.

Open the SQL tab.

Execute the following commands in the SQL tab of the phpMyAdmin utility or via the MySQL/MariaDB command line (pseudo code example):

Real example

We looked at the pseudo code above. Now let’s look at a real example. As part of your new WordPress database setup, replace the old default wp_ prefix with your new one.

In the real example below, we are replacing wp_ with cmj_ as our new database table prefix. The SQL command line would look as follows:

Once the above steps are complete, click Go to run the commands and complete the change. You have set the new custom database table prefix for your site’s WordPress database.

All is well and good now. The prefix on your WordPress database tables has been successfully changed. Thus, the custom prefix setup is completed, giving you an extra layer of security.

Ready to get started?

Get the fastest, most secure WordPress.org hosting on the market.

Trust us to help you choose the ideal hosting solution

Loading form…