How To Change WordPress Database Name

Last updated on September 13th, 2017 at 09:10 pm

How to change WordPress Database name. Below sharing the changing process.

Require access to phpMyAdmin, cPanel and File Manager.

Have to do a backup of your old database before proceding.

  1.  phpMyAdmin
    1. Left menu > Select name of database to change
    2. Top menu > Select “Operations”
    3. Key in the new name into the fields of “Rename database to:”
    4. renamedb.JPG
  2. If you surf to your website, you will see “Error establishing a database connection.”
  3. On the catagory menu of cPanel, “Database Tools”
    1. Select “MySQL Databases” to navigate to the page.
    2. mysql.JPG
    3. After changing the DB name from phpMyAdmin, the new name will appear in the list of “Current Databases” but without Privileged Users assigned.
    4. At bottom of the page there is MySQL User > “Add a User to a Database” function.
    5. There are 2 seperated dropdown menus for User and Database, select the correct new DB name assign a User
    6. Make sure you select the renamed Database. The old name of database sould not appear in the dropdown list.
    7. Finally, select the User to add.
  4. On the following page of “MySQL Databases” after adding,
    1. MySQL Account Maintenance
    2. Manage User Privileges by a tick on the checkbox of ALL PRIVILEGES.
    3. Click “Make Changes” to complete the process.
    4. Manage User Privileges.JPG
  5. Back to cPanel, select File Manager > Home Directory > Submit
    1. On File Manager, select public_html and select the correct subfolder where you installed the WordPress.
    2. Select wp-config.php file and use the integrated Code Editor tools to amend the file directly.
    3. Which lines of the code to change? Namely 2 lines to change. Look out for define(‘DB_NAME’ and define(‘DB_USER’.
    4. lines to change.JPG
    5. Update the old database and username to the new one.
    6. Remember to save and close the Editor.
  6. Check back that your website should be working properbly now.

Alternatively, changing database name through “MySQL Databases” works as good. The changes will reflect the new name in phpMyAdmin, eventually.

This will skip the manual changing from phpMyAdmin, however, there is no way for exporting the database table from MySQL Databases.

The latter step helps to backup of database before any changes made.

I have tried this method on my old database file, it turned out to have its size shown as zero. Over at phpMyAdmin, nothing seem to lose even with new name updated. After refresh of phpMyAdmin, it should reflect of correct file size.

To prevent any latter-issues, I would suggest the above mentioned steps at the start of the post.

Always backup of save the file to local storage before proceding the change.