The WordPress database is made up of tables, the tables all have the same prefix that is set during the WordPress installation.
In some cases it may be necessary to change the prefix of the tables, especially if it is the default one (wp_, wordpress_, etc.) which does not represent the maximum security. Let’s see how to change the prefix in 6 simple steps.
1: backup your database
This operation will modify the WordPress database so the first thing to do to be safe is to save the backup.
2: edit the wp-config.php file
In the WordPress root you find the configuration file “wp-config.php”. Search for the line:
$ table_prefix = ‘wp_’;
and change it to a new more secure prefix:
$ table_prefix = ‘example123_’;
Save the file.
3: Change the name of the database tables
Navigate to the phpMyAdmin panel and select your WordPress database. Click on the “SQL” menu and enter the command to rename all the tables. The process is to be performed for each table.
Whenever you paste a command line into the SQL window, click GO and check on the left column that the name is updated. Continue until all WordPress tables are renamed.
4: edit the wp_options field
Now you need to edit the example123_options options table (originally wp_options ).
Click on the link with the table name and then click on the “Browse” menu. You will see all the data stored in this table. Look at the “option_name” column and rename from wp_user_roles to example123_user_roles. To modify the string just click on the edit button (pencil) on the same line.
The wp_user_roles line may not appear on the first options page, keep looking for it otherwise you won’t be able to login.
5: edit the wp_usermeta field
As a last modification rename the field example123_usermeta (originally wp_usermeta). Do not leave out any data.
In phpMyAdmin select the example123_usermeta field and click the browse menu.
Change each value under the “meta_key” column, change the prefix from the old “wp_” to the new “example123_”, the number of data to change may vary from site to site:
To find out how many records you need to change, just run a query in SQL:
Click on the search link, enter these conditions (meta_key like ‘wp_%’), and click the GO button.
6: test the website
Check the site by browsing and logging in.
Alternatives
If you don’t want to get your hands dirty you can use the WP Prefix Changer plugin .