How to Rename WordPress Database Through phpMyAdmin

How to Rename WordPress Database Through phpMyAdmin

What is a WordPress database? Simply put, your WordPress database is a collection of data held in a web server that can be accessed through various means. It should be named in a personally descriptive way so that it is easy for you to remember and yet be different enough to be picked among others. That’s important when you need to make changes, as you do not want to change the wrong database.

As your WordPress database keeps all the important details of your site safe from hackers or unwanted intruders who can wreak havoc on your site, you’d better use a database name that isn’t easy to guess. Here we’d like to show you how to change the end of your database name through phpMyAdmin.

Step 1: Rename the database in phpMyAdmin

As cPanel is the most popular Linux based control panel that has graphic interface and provides automation tools to simplify the process of hosting a site, we take this one as an example.

Once you have logged in your control panel and clicked phpMyAdmin icon, you can find a list of databases from the screen. Select the one you want to rename. Make sure you pick the right one that corresponds to your site.

After clicking on the selected database, the panel simply changes and some useful tabs appear on the top margins. Now, you need to click on “Operations” tab to rename the database.

Operations Tab

Under “Rename database to” option, type in the new name you would like for your database in the text field and click “Go” on the bottom right corner of the field. You can choose to rename your database to whatever you like as long as it contains only letters and numbers. A popup window (SQL query) can appear to ask you to accept the change. Click “OK”.

Once you have done all this, your database has a new name but it fails to be matching with the wp-config.php file yet. It means that your site is broken so next you need to edit your wp-config.php file.

Step 2: Change database name in wp-config.php

Open up the root directory of your site. There are two ways to do this. One is by using an FTP program that is used to transfer files between computers on a network. With the connection, you can download the wp-config.php file and edit it in a text editor.

wp-config File

The other option is to use the inbuilt directory browser. In cPanel, select the wp-config.php file from the list and click the Edit button on the top of the page. If prompted, click Edit again.

Once the file is open, scroll down to reach “define(‘DB_NAME’, ‘your_db’) “. “your_db” is the original name of your database. Change “your_db” to the new name in the previous step. Save the file. If you are using FTP, upload the file back to the root directory. Now you’re almost done renaming your WordPress database!

Your DB Code

Step 3: Assign a user to the database and configure the user permissions

In cPanel, click on Databases section and select MySQL Databases. Then, you need to look for the option of “Add a User to a Database” and select your username from the drop down box. Your username is the same one that appears in the wp-config.php file on the same line as “DB_USER”.

Add a User to a Database

After that, go to the Database section and select the “Add” button from the Database drop down box. Tick the “All Privileges” checkbox at the top and click the “Make Changes” tab at the bottom left of the screen. Make sure that all the boxes are ticked. If you want additional users to have different permissions, you can choose to tick the options for each user.