If you’re running a WordPress site, it’s important to keep your database secure. One way to do this is by changing the default table prefix. In this post, we’ll show you how to change the WordPress table prefix in just a few steps.

Changing the WordPress table prefix is a relatively simple process, but it’s important to follow the steps carefully to avoid any errors.

But before we break down this process step-by-step, let’s first define what the WordPress table prefix is and offer up some things to think about before you make this change. Then we’ll discuss three different ways you can change the WordPress table prefix yourself.

Let’s dive in.


Why Change the WordPress Table Prefix?

The WordPress table prefix is the identifier for each table in your WordPress database. By default, the table prefix is set to wp_.

However, this default setting leaves your site vulnerable to attack since hackers know the prefix and can easily target it. So, if you’re serious about keeping your WordPress site secure, then you’ll need to change the default table prefix.

Changing the WordPress table prefix is a relatively simple process, but it’s important to follow the steps carefully to avoid any errors. Get started here ✅Click to Tweet

When Should You Change the WordPress Table Prefix?

You can change the WordPress table prefix any time, but it’s generally recommended to do it when you first install WordPress. This way, you don’t have to worry about changing the prefix for an existing site.

If you’re installing WordPress for the first time, simply follow the prompts and enter a new table prefix when prompted.

If you’re changing the WordPress table prefix for an existing site, you’ll need to take some additional steps, which we’ll discuss later in this post.

What To Consider Before Changing Your WordPress Table Prefix

Before you change the WordPress table prefix, there are a few things you need to take into consideration.

First, you need to make sure that you back up your WordPress database. This way, if anything goes wrong during the process, you can quickly restore your site.

Second, you need to be aware that changing the WordPress table prefix will break any existing plugins or themes that are currently active on your site. This is because they’re all stored in the database under the current table prefix.

So, if you do decide to change the WordPress table prefix, you’ll need to deactivate and then reactivate any existing plugins and themes. We’ll discuss how to do this later in the post.

Third, changing the prefix won’t stop all hackers if they are already able to exploit your site with SQL injections, but it will stop bot attacks which are the bulk of hacking attempts.

Fourth, the prefix set in your wp-config.php folder and the one used in your actual database must be the same, and every table needs to use the same prefix, or your site will break. It’s easy to break your site by doing this, so you shouldn’t if you don’t know what you’re doing.

And lastly, if you work in the database often, queries you find online use the default prefix, so changing it can be annoying.

Now that we’ve covered the basics let’s take a look at how to change the WordPress table prefix.

How To Change Your WordPress Table Prefix: 3 Methods

There are three methods you can use to change the WordPress table prefix. We’ll discuss each method in detail below.

Back Up Before You Begin

Back up your site and database, as changing the table prefix could break your entire site if done wrong. A backup will mean you can restore your site from that point should an error occur.

There are a few different ways you can back up your WordPress site. If you’re using a WordPress hosting provider, they may offer a backup service. Or, you can use a WordPress backup plugin. If you’re using MyKinsta, you can take advantage of backups automatically, as they are included with your plan.

If you require more control over your backups, however, you may wish to consider a backup add-on. Need more frequent backups? The Hourly Backups Add-on is a wise choice. Similarly, if you need to back external backups to Amazon S3 or Google Cloud Storage, the External Backup Add-on is a no-brainer.

Method 1: Manually

The first method we’ll discuss involves using FTP to directly change the wp-config.php file. We prefer using MyKinsta for this task. Here’s how to do it:

1. Log In to Your MyKinsta Account

Once you’re logged in, click on Sites in the left sidebar and then select the site you want to change the WordPress prefix for. Then click Info. Scroll down to the section called SFTP/SSH and copy the information there, including the Host, Username, Password, and Port.

Locating SFTP login details within MyKinsta.
Locating SFTP login details within MyKinsta.

2. Use This Info to Login to an FTP Client

Now you need to use this information to log in to an FTP client. We recommend using FileZilla. Once you’ve installed it, open the app and enter the information from MyKinsta into the fields for Host, Username, Password, and Port. Then click Quickconnect.

Alternatively, you can easily complete steps one and two via cPanel as well by logging into your hosting account, accessing the cPanel then going to File Manager.

3. Download the wp-config.php File

After you’re logged in, you should see a list of files on the right side. Find the wp-config.php file and download it to your computer by right-clicking on it and selecting Download from the menu.

4. Edit the wp-config.php File

Now open the wp-config.php file in a text editor like Sublime Text. Find the line that says

$table_prefix = ‘wp_’;

and change the ‘wp_' to the new prefix you want to use. Make sure to save the file when you’re done.

Editing the wp-config.php file in a text editor.
Editing the wp-config.php file in a text editor.

5. Upload the wp-config.php File

Now go back to FileZilla and find the wp-config.php file on your computer. Right-click on it and select Upload from the menu.

6. Rename all WordPress Tables in the Database with the New Prefix

The next step is to actually change the prefix for all the WordPress tables in your database. The default ones include:

  • wp_commentmeta
  • wp_comments
  • wp_links
  • wp_options
  • wp_postmeta
  • wp_posts
  • wp_terms
  • wp_term_relationships
  • wp_term_taxonomy

You should also pay attention to database tables outside of the defaults that plugins created as well.

To change the prefix, you need to access your database. You can do this via phpMyAdmin in cPanel. Or you can once again use MyKinsta for this task, which provides direct database access. Log into your account, navigate to Sites > Your Site > Info, and click on the link that says Open phpMyAdmin.

Accessing phpMyAdmin using MyKinsta.
Accessing phpMyAdmin using MyKinsta.

Click on the database name in the left sidebar. Then, click on the SQL tab at the top of the page. In the text box, enter this query:

RENAME table wp_xxxx TO newprefix_xxxx;

Of course, you need to replace newprefix with your actual new prefix. For instance, if you were changing the database prefix for wp_comments, it would appear as newprefix_comments after you make the change.

Adding an SQL query to phpMyAdmin to change the database prefix.
Adding an SQL query to phpMyAdmin to change the database prefix.

Then click the Go button.

Repeat this process for all of the WordPress tables in your database, changing wp_ to your new prefix.

Be sure to search the options and usermeta tables for the old prefix to ensure you’ve changed and updated everything.

7. Deactivate and Reactivate All Plugins and Themes

The next step is to deactivate all plugins and themes. You need to do this because the plugins and themes were installed using the old prefix and will need to be refreshed, so to speak, using the new prefix.

You can do this by going to the Plugins and Themes pages in your WordPress admin dashboard. Once all plugins and themes are deactivated, reactivate them one by one to ensure they work properly under the new database prefix.

8. Test Your WordPress Site

Once you’ve changed the prefix for all the WordPress tables in your database, you can test your WordPress site to make sure everything is working properly. To do that, simply visit your WordPress site in a web browser. If it loads without any errors, then you’re good to go. You can also use a tool like Kinsta APM to conduct continual performance monitoring to ensure your site’s performance remains in tip-top shape.

Method 2: Using a Plugin

If you’re not comfortable working with code or accessing your database directly, then you can also use a plugin to change the WordPress prefix. We recommend the Brozzme DB Prefix & Tools Addons plugin for this task.

Struggling with downtime and WordPress problems? Kinsta is the hosting solution designed to save you time! Check out our features
Brozzme DB Prefix & Tools Addon plugin
Brozzme DB Prefix & Tools Addon

1. Install and Activate the Plugin

First, you need to install and activate the plugin. You can do this from the WordPress admin area by going to Plugins > Add New and searching for Brozzme DB Prefix & Tools Addons.

Installing the Brozzme DB Prefix & Tools Addon plugin in WordPress
Installing the Brozzme DB Prefix & Tools Addon plugin in WordPress

Once you’ve found it, click Install Now and then Activate.

2. Change the Database Prefix

Now that the plugin is activated, you can change the WordPress database prefix by going to Tools > DB Prefix.

The Brozzme plugin’s Settings page is pretty straightforward.
The Brozzme plugin’s Settings page is pretty straightforward.

On this page, you need to enter your new database prefix in the New Prefix field. Then click the Change DB Prefix button.

The plugin will now update all of your WordPress tables with the new prefix.

3. Test Your WordPress Site

After the plugin has updated your database, you can test your WordPress site to make sure it’s still functional. As before, open your web browser and navigate to your live site. If everything looks as it should, the update worked.

Method 3: Using Adminer

If you don’t want to use a plugin, then you can also change the WordPress database prefix using Adminer. Adminer is a standalone PHP script that allows you to manage your databases.

1. Download and Install Adminer

To get started with Adminer, you will need to download the latest version from the official website. Once you have it, you need to upload this PHP file to your website’s root server. You can do this via FTP using a tool like FileZilla, as we’ve described in previous steps.

Once Adminer is uploaded, you can access it directly via your web browser. The latest version is 4.8.1, so if you’ve placed it in your site’s root directory, you can access it by going to https://your-website.com/adminer-4.8.1.php.

2. Run SQL Queries

From here, you can access and log in to any database on your server. However, we only want to change the WordPress database prefix so you can ignore all of the other databases.

The SQL Command view within Adminer.
The SQL Command view within Adminer.

On this page, select your WordPress database from the left sidebar. Then click on the SQL Command tab at the top of the page.

In the text box, enter this query:

RENAME table wp_xxxx TO newprefix_xxxx;

Of course, you need to replace newprefix with your actual new prefix. For instance, if you were changing the database prefix for wp_usermeta, it would appear as newprefix_usermeta after you make the change.

Then click the Execute button.

Repeat this process for all of the WordPress tables in your database, changing wp_ to the new prefix of your choosing.

3. Test Your WordPress Site

After you’ve updated the prefix for all of your WordPress tables in your database, you may test your website to ensure that everything is functioning properly. Simply go to your WordPress site in a web browser and see whether it loads without issues. If all is well, you’re all done.

Congratulations! You’ve successfully changed the WordPress database prefix and updated your site accordingly.

If you’re running a WordPress site, it’s important to keep your database secure. 🔒 One way to do this is by changing the default table prefix- and this guide can help 🚀Click to Tweet

Summary

Changing the WordPress database prefix is a good way to improve the security of your site. By default, the WordPress database prefix is wp_ but you can easily change it to something else.

Here we reviewed three ways to change the WordPress database prefix: by editing the wp-config.php file, using a plugin, or using Adminer.

We hope this article helped you learn how to confidently change the WordPress database prefix.

And if you’re interested in a WordPress site management solution that streamlines your workflow, MyKinsta is always a good option. With robust security features, speed optimization, and backups included, it’s hard to go wrong here.


Get all your applications, databases and WordPress sites online and under one roof. Our feature-packed, high-performance cloud platform includes:

  • Easy setup and management in the MyKinsta dashboard
  • 24/7 expert support
  • The best Google Cloud Platform hardware and network, powered by Kubernetes for maximum scalability
  • An enterprise-level Cloudflare integration for speed and security
  • Global audience reach with up to 35 data centers and 275+ PoPs worldwide

Test it yourself with $20 off your first month of Application Hosting or Database Hosting. Explore our plans or talk to sales to find your best fit.