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.
The WordPress table prefix is the identifier for each table in your WordPress database. By default, the table prefix is set to .
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.
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.
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 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.
There are three methods you can use to change the WordPress table prefix. We’ll discuss each method in detail below.
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.
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:
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.
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.
After you’re logged in, you should see a list of files on the right side. Find the file and download it to your computer by right-clicking on it and selecting Download from the menu.
Now open the file in a text editor like Sublime Text. Find the line that says
and change the to the new prefix you want to use. Make sure to save the file when you’re done.
Now go back to FileZilla and find the file on your computer. Right-click on it and select Upload from the menu.
The next step is to actually change the prefix for all the WordPress tables in your database. The default ones include:
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.
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:
Of course, you need to replace with your actual new prefix. For instance, if you were changing the database prefix for , it would appear as after you make the change.
Then click the Go button.
Repeat this process for all of the WordPress tables in your database, changing 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.
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.
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.
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.
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.
Once you’ve found it, click Install Now and then Activate.
Now that the plugin is activated, you can change the WordPress database prefix by going to Tools > DB Prefix.
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.
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.
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.
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.
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.
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:
Of course, you need to replace newprefix with your actual new prefix. For instance, if you were changing the database prefix for , it would appear as after you make the change.
Repeat this process for all of the WordPress tables in your database, changing to the new prefix of your choosing.
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
Changing the WordPress database prefix is a good way to improve the security of your site. By default, the WordPress database prefix is but you can easily change it to something else.
Here we reviewed three ways to change the WordPress database prefix: by editing the 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.