> ## Documentation Index
> Fetch the complete documentation index at: https://kb.hosting.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Renaming a MySQL database

> Learn how to rename a MySQL database with this complete walkthrough including detailed instructions, relevant code snippets, and links to related articles.

This article explains how to rename a MySQL database.

## Renaming a MySQL database

You may need to rename a MySQL database from time to time, such as when you migrate data from one account or hosting provider to another, or during site development.

The steps to rename a MySQL database depend on whether or not your hosting.com account includes cPanel access.

### Managed accounts with cPanel

If your hosting.com account includes cPanel access, you can use cPanel to quickly and easily rename a MySQL database. To do this, follow these steps:

1. Log in to cPanel.
   > 📘 Note
   >
   > If you do not know how to log in to your cPanel account, please see [this article](/docs/accessing-cpanel).

2. On the **Tools** page, in the **Databases** section, click **Manage My Databases**:\
   ![cPanel - Databases - Manage My Databases icon](https://static.hosting.com/kb/kb-cpanel-120-databases-manage-my-databases-icon.png)

   > 📘 Note
   >
   > If you are using cPanel version 118 or earlier, click **MySQL Databases** instead:\
   > ![cPanel - Databases - MySQL Databases icon](https://static.hosting.com/kb/kb-cpanel-jupiter-databases-mysql-databases-icon.png)

3. Under **Current Databases**, locate the database you want to rename.

4. In the **Actions** column, click **Rename**:\
   ![cPanel - MySQL Databases - Rename](https://static.hosting.com/kb/kb-cpanel-paper-lantern-databases-rename.png)

   The **Rename Database** dialog box appears.

5. In the **New name** text box, type the new name for the database:\
   ![cPanel - MySQL Databases - Rename Database dialog box](https://static.hosting.com/kb/kb-cpanel-paper-lantern-mysql-rename-dialog-box.png)

6. Click **Proceed**. cPanel renames the database.

### Unmanaged accounts without cPanel

If your hosting.com account does not include cPanel, you can rename a MySQL database manually from the command line. To do this, follow these steps:

1. Log in to your server [using SSH](/docs/using-ssh-secure-shell).

2. At the command prompt, type the following command to create a new database. Replace ***username*** with the MySQL username, and replace ***new\_dbname*** with the new database name that you want to use:

   ```bash theme={null}
   mysql -u username -p -e "CREATE DATABASE new_dbname"
   ```

3. To export the old database to a file, type the following command. Replace ***username*** with the MySQL username, and replace ***old\_dbname*** with the name of the database that you want to rename:

   ```bash theme={null}
   mysqldump --routines -u username -p old_dbname > dbexport.sql
   ```

4. To import the data from the old database into the new database that you created in step 1, type the following command. Replace ***username*** with the MySQL username, and replace ***new\_dbname*** with the name of the new database:

   ```bash theme={null}
   mysql -u username -p new_dbname < dbexport.sql
   ```

5. To delete the old database, type the following command. Replace ***username*** with the MySQL username, and replace ***old\_dbname*** with the name of the database to delete:

   ```bash theme={null}
   mysql -u username -p -e "DROP DATABASE old_dbname"
   ```

   > 📘 Note
   >
   > This step is optional. You do not have to delete the old database.

6. You can now use the new database named ***new\_dbname***, which contains all of the tables and data from the old database.

## Related articles

* [Connecting to MySQL from the command line](/docs/connect-to-mysql-from-the-command-line)

* [Importing and exporting a MySQL database](/docs/import-and-export-a-mysql-database)

* [Managing MySQL databases, users, and tables from the command line](/docs/managing-mysql-databases-and-users-from-the-command-line)
