It is very important that a WordPress database is secure and organized because this database contains all the website’s information. The information in the WordPress database is stored on a web server.
One way of keeping the database secure is by giving it a proper name that makes keeping track of it easy. When choosing a name for the database, make sure that the name is descriptive and unique.
When WordPress generates a new database it is normally assigned a default name, like db_wordpress123. Make it a practice to change this name from the start to something like db_mysite. This avoids a lot of confusion, especially when running more than one WordPress site.
A personalized name that describes the content the database refers to is a way of keeping track of a WordPress site. It prevents one from making the wrong changes to the wrong database because they have the same name.
It also adds to security because it makes it more difficult for hackers to guess what the name of the database is and thus access the site’s details. The conclusion is that a name should be descriptive and distinctive.
This post will show how to change the WordPress database name’s ending so that it is recognizable and unique. With a little experience, this is a 10-minute job.
What is a Database and How WordPress Uses it?
A database is an organized way for storing information and retrieving it when necessary. Because of the high level of organization of the data, it is possible to program and automate the data management. WordPress uses the programming language PHP to communicate with the database.
Among the information that goes into the database are fields, pages, posts, and other WordPress settings. A future article will elaborate further on the exact items that a database contains.
When installing WordPress, it will ask for a name for the database, host username, and password. WordPress uses a configuration file with the name wp-config.php to store that information.
Later, WordPress refers back to the configuration file to create tables and save installation data in those tables.
It structures the database after all the information is gathered. Then it continues to communicate with it to generate HTML pages for the website or blog.
WordPress employs MySQL to manage the database. MySQL is an open-source software solution for managing information. It takes care of sorting user data, posts, comments, user meta, and more.
Change Database Name in phpMyAdmin
Change the database name through phpMyAdmin. This is an open-source application that is specially made for MySQL database management. It is a common tool for various web-hosting services.
This section will show how to use phpMyAdmin to change the WordPress database.
Edit Your Database
To start this method
- login to the cPanel and locate phpMyAdmin.
- In the left panel find the database in question and click on it.
- Click the Operations
- Enter the new name in the textbox under Rename Database.
- Click the Go bottom at the bottom right.
- Accept the change when prompted.
What it does is that it creates a new database with the new name and then imports the information from the old database to this new one.
This is the first part of the process. Now that the database has a new name the next step is to make sure that the wp-config.php file reflects these changes. Without updating the configuration file, the changes will not take effect.
Finding the wp-config.php File
As described above, the wp-config.php file is part of the setup of any self-hosted WordPress site. It does not come ready-made with WordPress. Rather, WordPress generates it upon installation. In fact, most web-based scripts have a similar configuration. These config files contain instructions on how to function and database information.
Access it by going to the website’s files. These files are accessible through the file manager from CPanel or using an FTP client.
Locating the WordPress Database Name
Right-click the wp-config.php file and select Edit or View. This action works both in the CPanel file manager and FTP client.
Inside the file, locate the value with the description DB_NAME. The text after this value is the name of the WordPress database. To find it fast use the search function. In Windows, this is with Ctrl+F and on a Mac computer CMD+F.
The code that contains the information looks like this:
//**MySQL settings - You can get this info from your web host **// /**MySQL database username */ define('DB_USER', 'yourusername'); /**MySQL database password */ define('DB_PASSWORD', 'this-is-your-password'); /**MySQL hostname */ define('DB_HOST', 'localhost'); /** Database Charset to use in creating database tables. */ define('DB_CHARSET', 'utf8');
Usually, this section is one of the first things in the file. When the DB_NAME line is found, replace ‘your_db‘ with the new name that was saved through phpMyAdmin. Here, ‘your_db’ corresponds to the old name of the database. Do not forget to save the changes to the wp-config.php file.
Once inside the configuration file, also check the following values:
These are other important database details.
Instead of using the cPanel method, it is also possible to download the file through an FTP client and use a text editor to make the changes.
Assign a Database User
Now that the name has been adjusted and the wp-config.php configured, there is one more thing to do. Take a little bit of time to add a database user. This is done from cPanel.
- Click MySQL Databases.
- Scroll down and find Add a User to a Database
- Add the user that was assigned to the new site to the newly created database. To know who that is, check the DB_USER line in the wp-config.php file. See the section above to learn how to do that.
- In the drop-down box select the new database.
- Click Add.
- On the next page, select All Privileges.
- Click Make Changes.
- Reactivate all plugins
Ending thoughts on how to change the WordPress database name
Double-check that everything is working properly by visiting the WordPress website. The website is now more secure and better organized.
If you enjoyed reading this article on how to change the WordPress database, you should check out this one on how to check the WordPress version.
We also wrote about a few related subjects like how to watermark images, creating a comparison table with WordPress plugins, how to upload an HTML file in WordPress, where are WordPress pages stored, why is WordPress so hard to use, and how to delete WordPress themes.