Yogesh Chauhan's Blog

How to change your WordPress database prefix?

in WordPress on December 28, 2021

Similar Reads:

How to invalidate all existing cookies using Security Keys in WordPress?

How to add MySQL alternate port and sockets/pipes in WordPress?

To change your WordPress database prefix, you need to make changes to wp-config.php file.

WordPress uses $table_prefix variable’s value to set the prefix for the database tables.

By default $table_prefix variable’s value set as “wp_”. That’s why when you install the WordPress, you’ll see the database tables with column names starting with “wp_”.

You can change the value of $table_prefix variable and replace it with whatever value you’d want to set. For e.g. if you add “yc_” as $table_prefix variable’s value then all of your basic WordPress table will have column names starting with “yc_”.

Do you need to change database prefix?

Not really.

Unless you really want to. OR if you want to have WordPress multisite when you’ll have multiple websites connected to the same database.

You can have different databases for each site too but in case you want to have all the sites in multisite connected to the same database then you need to use $table_prefix to set a different database prefixes for each site.

Be sure to look at the security aspect of the websites in case you decide to go for it.

How to set table_prefix value for Multiple WordPress Instances?

If you want to have multiple WordPress instances with a single database, you need to set table_prefix value for each instance.

For e.g. if you want to have 4 instances of WordPress under one database — let’s say Main, Finance, Human Resources, Information Technology then you’d want to set table_prefix values like this:

Each $table_prefix needs to be added in each site’s separate wp-config.php file.


$table_prefix = 'main_'; 


$table_prefix = 'fin_';  


$table_prefix = 'hr_'; 


$table_prefix = 'it_'; 


Most Read

#1 Solution to the error “Visual Studio Code can’t be opened because Apple cannot check it for malicious software” #2 How to add Read More Read Less Button using JavaScript? #3 How to check if radio button is checked or not using JavaScript? #4 Solution to “TypeError: ‘x’ is not iterable” in Angular 9 #5 How to uninstall Cocoapods from the Mac OS? #6 PHP Login System using PDO Part 1: Create User Registration Page

Recently Posted

#Apr 8 JSON.stringify() in JavaScript #Apr 7 Middleware in NextJS #Jan 17 4 advanced ways to search Colleague #Jan 16 Colleague UI Basics: The Search Area #Jan 16 Colleague UI Basics: The Context Area #Jan 16 Colleague UI Basics: Accessing the user interface
You might also like these
How to clean up after a plugin uninstall in WordPress?WordPressHow to Find the Highest (or Lowest) Number in an Array in JavaScript?JavaScriptWordPress: How to loop through ACF group fields?WordPressCreate a simple bar chart and column chart using pure CSS gridCSSWhat does Containment mean in React?Reactaddcslashes() and addslashes() String Functions in PHPPHP