In this guide, we explain how to change the database table prefix of your WordPress installation. The default database table prefix for WordPress is ‘wp_’; however, we recommend changing it. The reason for this is that all your login details are stored in your database, making your WordPress tables very popular targets for hackers. Changing the prefix makes it harder for them to break in.
Supper admin 2022-02-25 08:49:22 0 Bình Luận 284 Lượt xem
Change the table prefix for WordPress
In this guide, we explain how to change the database table prefix of your WordPress installation.
The default database table prefix for WordPress is ‘wp_’; however, we recommend changing it. The reason for this is that all your login details are stored in your database, making your WordPress tables very popular targets for hackers. Changing the prefix makes it harder for them to break in.
Note: If you have used the 1-click installer to install WordPress, then you already have a custom table prefix.
You need to change the table prefix in three places:
$table_prefix = 'wp_';
$table_prefix = 'david_';
In some settings that are stored in your database, WordPress still refers to the old table prefix. To complete changing the prefix, you need to replace these with your new prefix.
update NEWPREFIX_usermeta set meta_key = 'NEWPREFIX_capabilities' where meta_key = 'OLDPREFIX_capabilities'; update NEWPREFIX_usermeta set meta_key = 'NEWPREFIX_user_level' where meta_key = 'OLDPREFIX_user_level'; update NEWPREFIX_usermeta set meta_key = 'NEWPREFIX_autosave_draft_ids' where meta_key = 'OLDPREFIX_autosave_draft_ids'; update NEWPREFIX_options set option_name = 'NEWPREFIX_user_roles' where option_name = 'OLDPREFIX_user_roles';
update david_usermeta set meta_key = 'david_capabilities' where meta_key = 'wp_capabilities'; update david_usermeta set meta_key = 'david_user_level' where meta_key = 'wp_user_level'; update david_usermeta set meta_key = 'david_autosave_draft_ids' where meta_key = 'wp_autosave_draft_ids'; update david_options set option_name = 'david_user_roles' where option_name = 'wp_user_roles';
You are done. The prefix of the WordPress tables has now been changed.
All the options and events can be found in official documentation