> ## 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 PostgreSQL database

> Discover how to rename a PostgreSQL database on cPanel with this concise guide featuring instructions, code snippets, and visuals.

This article explains how to rename a PostgreSQL database.

## Renaming a PostgreSQL database

You may need to rename a PostgreSQL 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 PostgreSQL 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 PostgreSQL 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. In the **DATABASES** section of the cPanel home screen, click **PostgreSQL Databases**:\
   ![cPanel - PostgreSQL Databases icon](https://static.hosting.com/kb/kb-cpanel-78-databases-postgresql-databases.png)

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

4. In the **Actions** column, click **Rename**:\
   ![cPanel - PostgreSQL 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 - PostgreSQL Databases - Rename dialog box](https://static.hosting.com/kb/kb-cpanel-paper-lantern-postgresql-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 quickly and easily rename a PostgreSQL database 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 connect to PostgreSQL. Replace ***dbname*** with the name of a database that is **not** the database you want to rename, and replace ***username*** with a PostgreSQL username that has access privileges to the database:

   ```bash theme={null}
   psql dbname username
   ```

   > 🚧 Important
   >
   > You cannot rename a database while you are currently connected to it.

3. To rename the database, type the following command. Replace ***old\_dbname*** with the name of the database that you want to rename, and replace ***new\_dbname*** with the database's new name:

   ```sql theme={null}
   ALTER DATABASE "old_dbname" RENAME TO "new_dbname"
   ```

4. To verify that the database was renamed, type the following command to list the databases:

   ```bash theme={null}
   \list
   ```

## Related articles

* [Connecting to PostgreSQL using psql](/docs/connect-to-postgresql-from-the-command-line)

* [Importing and exporting a PostgreSQL database](/docs/import-and-export-a-postgresql-database)
