Nexura Security
Download Free

100% Free · No credit card required

Back to Blog
Tutorials August 19, 2026 4 Views

Changing the Default WordPress Database Prefix (Step-by-Step)

nexurasecurity
Nexura Security
Security Researcher
Changing the Default WordPress Database Prefix (Step-by-Step)

Why Change the Database Prefix?

When you install WordPress, the default prefix for all your database tables is wp_ (e.g., wp_users, wp_posts). Because this is universal, hackers write automated SQL injection scripts that blindly target these exact table names.

By changing your prefix to something unique (like nx74_sec_), you implement "Security by Obscurity." While this won't stop a targeted, manual attack, it will successfully deflect 99% of automated, indiscriminate bot attacks.

Need immediate help?

If your site is currently hacked or showing warnings, our incident response team can help right now.

Fix My Site Now

How to Change the Prefix Safely

Crucial: Before you begin, take a complete backup of your database. A mistake here will break your website instantly.

Step 1: Edit wp-config.php

Access your site via FTP. Open wp-config.php and find the line:

Sponsored Pro Version

Upgrade to Nexura Pro

Get enterprise-grade protection. Block zero-day exploits, advanced malware, and brute-force attacks instantly.

Get 50% Off Now

LIMITED TIME LAUNCH OFFER

$table_prefix = 'wp_';

Change it to your new, random prefix (use only letters, numbers, and underscores):

$table_prefix = 'nx74_sec_';

Step 2: Rename Tables in the Database

Log in to phpMyAdmin via your hosting control panel. Select your WordPress database. You must run an SQL query to rename every single table. Go to the SQL tab and run commands like this for all tables:

RENAME table `wp_commentmeta` TO `nx74_sec_commentmeta`;
RENAME table `wp_comments` TO `nx74_sec_comments`;
RENAME table `wp_links` TO `nx74_sec_links`;
RENAME table `wp_options` TO `nx74_sec_options`;
RENAME table `wp_postmeta` TO `nx74_sec_postmeta`;
RENAME table `wp_posts` TO `nx74_sec_posts`;
RENAME table `wp_termmeta` TO `nx74_sec_termmeta`;
RENAME table `wp_terms` TO `nx74_sec_terms`;
RENAME table `wp_term_relationships` TO `nx74_sec_term_relationships`;
RENAME table `wp_term_taxonomy` TO `nx74_sec_term_taxonomy`;
RENAME table `wp_usermeta` TO `nx74_sec_usermeta`;
RENAME table `wp_users` TO `nx74_sec_users`;

Step 3: Update the wp_options Table

WordPress stores some settings using the old prefix. You must update them. Run this query:

SELECT * FROM `nx74_sec_options` WHERE `option_name` LIKE '%wp_%';

Update any option names (like wp_user_roles) to use the new prefix (nx74_sec_user_roles).

Step 4: Update the wp_usermeta Table

Finally, update user permissions, which also rely on the prefix:

SELECT * FROM `nx74_sec_usermeta` WHERE `meta_key` LIKE '%wp_%';

Update all corresponding `meta_key` entries.

The Easier Way

Doing this manually is terrifying for non-developers. Nexura Security offers a 1-click database prefix changer in its Pro version, handling all the SQL queries, options, and usermeta updates safely and automatically in seconds.

Share this article:
Nexura Security Team

Nexura Security Research Team

WordPress Security Experts

The Nexura Research Team continuously monitors the WordPress ecosystem for emerging threats, zero-day vulnerabilities, and malware trends. Our mission is to provide actionable intelligence to keep your websites secure, fast, and resilient against modern cyber attacks.

nexurasecurity

Written by Nexura Security

Did this article help? If you need professional assistance implementing these security measures or recovering from a hack, we are just a click away.

Comments (0)

No comments yet. Be the first to share your thoughts!

Leave a Comment

You must be logged in to post a comment.

Log In

Secure Your WordPress Site Today

Get enterprise-grade protection with Nexura Security. Setup takes less than 60 seconds.

Download Free Plugin

Stay Ahead of Hackers

Join our growing community of site owners who receive our weekly WordPress security alerts, vulnerability reports, and hardening tips.

SSL Secured
GDPR Compliant
WP.org Verified
OWASP Protected
Secure Your Infrastructure Today