Warning: include(footer.php): failed to open stream: No such file or directory in /home/u799281109/domains/digitalmarketinginstitute.in/public_html/wp-content/themes/webempire-child/header.php on line 46

Warning: include(): Failed opening 'footer.php' for inclusion (include_path='.:/opt/alt/php74/usr/share/pear') in /home/u799281109/domains/digitalmarketinginstitute.in/public_html/wp-content/themes/webempire-child/header.php on line 46
SQL Scripts to Change Default _wp WordPress Database Prefix - Ashish Kulkarni

SQL Scripts to Change Default _wp WordPress Database Prefix

Where is all information and content about your WordPress site is stored? It is the WordPress database. Hence, the database is the first place where hackers will try their luck and attack. Spammers and hackers will try to run automated codes for SQL injections. If you do not change the default database prefix while installing the WordPress, you are more vulnerable to an attack. Hackers will first try and attack default _wp prefix.

In this blog post, I am sharing with you the SQL scripts which will help you in changing the default _wp database prefix properly within minutes.

Preparation

I suggest that you take a back up of your existing database.

Change Database Table Prefix

You will have to rename the database tables and to do this all you need is access to PhpMyAdmin.

PHP My Admin

PHP My Admin

Let us assume that for security reasons you want to change WordPress database prefix from ‘_wp’ to ‘_wp_zjdu_’. I am sharing with you a list of SQL scripts that if executed will change the default _wp database prefix to _wp_zjdu_ by renaming tables.

  1. Log into phpMyAdmin
  2. Choose correct database
  3. Click on SQL tab on the top
  4. Copy & paste below SQL queries, click on Go
Database Structure

Database Structure

SQL Scripts:

Copy and execute below scripts all at once, this will change default prefix _wp to _wp_zjdu_ by renaming tables.

RENAME table `wp_commentmeta` TO `wp_zjdu_commentmeta`;
RENAME table `wp_comments` TO `wp_zjdu_comments`;
RENAME table `wp_links` TO `wp_zjdu_links`;
RENAME table `wp_options` TO `wp_zjdu_options`;
RENAME table `wp_postmeta` TO `wp_zjdu_postmeta`;
RENAME table `wp_posts` TO `wp_zjdu_posts`;
RENAME table `wp_terms` TO `wp_zjdu_terms`;
RENAME table `wp_term_relationships` TO `wp_zjdu_term_relationships`;
RENAME table `wp_term_taxonomy` TO `wp_zjdu_term_taxonomy`;
RENAME table `wp_usermeta` TO `wp_zjdu_usermeta`;
RENAME table `wp_users` TO `wp_zjdu_users`;
RENAME table `wp_termmeta` TO `wp_zjdu_termmeta`;

Options & Usermeta Table

Below two scripts will require some manual work. First, execute these scripts one after another, look for results. From the records, manually replace wp_ to wp_zjdu_ and save records.

Execute:

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

Action:

From the records, manually replace _wp to wp_zjdu_ and save records.

Execute:

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

Action:

From the records, manually replace _wp to wp_zjdu_ and save records.

Options & Usermeta Table

Options & Usermeta Table

Change Table Prefix in wp-config.php

WordPress needs to know that you have changed default _wp table prefix. Instruct WordPress to use new table prefix by changing wp-config.php file. Open your wp-config.php file which is located in your WordPress root directory. Change the table prefix line from wp_ to wp_zdju_ and save this file.

So the line would look like this:

$table_prefix = ‘wp_zdju_’;
Note: You can only change it to numbers, letters, and underscores.

wp-config.php

wp-config.php

Done:

You are done. Now, test your website, it should be working as usual. I suggest you take a back up of the database after susccessfully increasing security of your WordPress database by changing default database prefix in WordPress.

Tags:
0 Comments

Leave a reply

Your email address will not be published. Required fields are marked *

*

© 2006-2022 Ashish Kulkarni, All rights reserved. Use of and/or registration on any portion of this site constitutes acceptance of my Privacy Policy and Cookie Statement (updated 5/25/18). AshishKulkarni.net may earn a portion of sales from products that are purchased through my site as part of Affiliate Partnerships with retailers. The material on this site may not be reproduced, distributed, transmitted, cached or otherwise used, except with the prior written permission of Mr Ashish Kulkarni.

Contact Me

I a not around right now. But you can send me an email and I will get back to you, asap.

Sending

Log in with your credentials

or    

Forgot your details?

Create Account