MySQL doesn't have a built-in "rename" command for databases, so you can't just edit the name in a settings screen. The reliable way to rename a database on shared hosting is to use phpMyAdmin's Operations tab, which handles the copy-and-drop process for you in one step. This works the same way whether your account is on cPanel or DirectAdmin, since both include phpMyAdmin.
Renaming a database is not instantly reversible. Take a backup or export first, and expect a short window where your website can't reach the database while you update its configuration.
Before You Start
Back up the database you're about to rename. You can do this quickly through phpMyAdmin's export tool - see our guide on importing and exporting a MySQL database using phpMyAdmin if you haven't done this before.
Also note down which database user is currently linked to the database, and what privileges they have. You'll need to reconnect that user once the rename is done.
Renaming the Database in phpMyAdmin
- Log in to phpMyAdmin from your control panel.
- In the left-hand list, click the database you want to rename.
- Click the Operations tab.
- Under Rename database to, type the new name and click Go.
- Confirm the action when prompted. phpMyAdmin creates a new database with the name you entered, copies every table and its data across, then deletes the original database.
Depending on how many tables and how much data the database holds, this can take anywhere from a few seconds to a few minutes. Avoid closing the browser tab until it finishes.
If your hosting account doesn't show an Operations tab for a database, export the database, create a new empty one with the correct name, and import the backup into it instead.
Reconnecting the Database User
Renaming the database doesn't carry over user privileges automatically, so you'll need to reattach your database user in your control panel.
In cPanel
- Go to MySQL® Databases.
- Under Add User to Database, select your existing database user and the newly renamed database.
- Click Add, then tick the privileges the user needs (usually All Privileges) and click Make Changes.
In DirectAdmin
- Go to MySQL Management.
- Find the renamed database in the list and click Modify Privileges next to the user who needs access.
- Tick the required privileges and save the changes.
Update Your Website's Configuration
Once the user is reconnected, update the database name everywhere your website references it. For a WordPress site, this means editing the DB_NAME line in wp-config.php. Other platforms store this in a similar configuration file or environment variable, so check your app's settings before assuming the rename is complete.
Test the website immediately after updating the configuration. If you see a database connection error, double-check that the new database name, the username, and the password all match what's in your configuration file.