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