This is a simple guide that helps people easily change the database name in WordPress sites. By this way, they can be effective to increase the site security and clearly identify the purpose and content of multiple databases.
Changing database name is a common operation that is handled by many people for specific purposes. Some people install WordPress sites with the automatic methods via some 1-click installer, and generate the database with a default name that is easy to guess by others, which is a great threat for site security. In addition, with the default name like “wpdb1”, “wpdb2”, it’s a hard thing for people who have multiple sites installed to tell which database belongs to which site. For these similar cases, you can solve problems by changing the default database name.
In the below, we introduce the process in details, combining with words and illustrations, with which you can easily follow the guidelines step-by-step.
Before doing changes, you should backup your website and database so that you can restore the website as soon as possible if something is wrong in the process. If you are confused about this step, you can follow this guide or take use of some site backup plugins.
During the process, your site will have several minutes of downtime. Thus, we suggest you to create a 404 error page or redirect the domain to a page that tells something like “under building, please back in a few minutes” to increase your site user experience.
If you are non-technician and have little confidence for the operations, you can complete the process on a testing site instead of your live site.
Change the Database Name via phpMyAdmin
To change the name, we take use of phpMyAdmin, which is a software tool designed for database management. You can find it by logging into your web hosting control panel and go to Databases section.
Click the icon and you can easily log into phpMyAdmin admin panel. Then, click on Databases tab on the top menu bar and it will list out all your databases on the server.
Open on the database which you want to change the name, and then click on the Operations tab on the top menu bar.
Then, you can see an selection as “Rename database to”, where you can change its name as anything you like. Click on Go button to save the changes.
At present, you have changed the database name, but your server doesn’t know the actions. So what you need to do in the next step is to change database name in the WordPress configuration file to ensure that the site can successfully connect to the database.
Change Database Name in wp-config.php File
Back to your control panel and click through File Manager under the Files section. Then, choose the file manager directory as the document root for your site.
Then, you can find the file named wp-config.php in your root directory, which is a basic configuration file of WordPress sites. Right click on this file, and then you can click the Edit to open this file.
Once opened this file, you can find the database name define line like the following. Or you can find this line by browse the “DB_NAME” in the editor. Then, you can change the value as the new database name. At last, click on the button of Save Changes to complete the process.
Once this is done, you have completely changed the database name. You can now go to your site and checkout the result. If everything looks like it performed before, the operation is successful.