How to rename a MySQL database - Rocketeers app

  [ Rocketeers ](/)   

[Login](https://rocketeersapp.com/login) 

 On this page

 Knowledge
---------

How to rename a MySQL database
==============================

### [\#Databases](https://rocketeersapp.com/knowledge/databases)

Unlike renaming a table, you can't rename a database in MySQL sadly enough. So there is no SQL query you can execute to achieve this. However, it is possible with a workaround.

 Published by [Mark van Eijk](https://rocketeersapp.com/author/mark-van-eijk) on September 24, 2024 
Updated on September 25, 2024 · 1 minute read

1. [Create a newly named database](#content-create-a-newly-named-database)
2. [Dump &amp; import](#content-dump--import)
3. [Drop the old database](#content-drop-the-old-database)

The most important step: To get going with this, first [create a full backup of your MySQL database](/backup-mysql-databases-single-file) to make sure you don't loose any data!

[\#](#content-create-a-newly-named-database "Permalink")Create a newly named database
-------------------------------------------------------------------------------------

This step involves creating the database you want to rename the old database to:

 ```
CREATE DATABASE `NEW_DATABASE_NAME`;

```

[\#](#content-dump--import "Permalink")Dump &amp; import
--------------------------------------------------------

Dump and import the old database into your new database:

 ```
mysqldump -u USERNAME -p OLD_DATABASE_NAME | mysql -u USERNAME -p NEW_DATABASE_NAME

```

[\#](#content-drop-the-old-database "Permalink")Drop the old database
---------------------------------------------------------------------

If your really sure, you can (with the backup on hand) remove the old database safely:

 ```
DROP DATABASE `OLD_DATABASE_NAME`

```

### Subscribe to our newsletter

Do you want to receive regular updates with fresh and exclusive content to learn more about web development, hosting, security and performance? Subscribe now!

  Fill in your email address to receive updates  Subscribe 

#### More in [\#Databases](https://rocketeersapp.com/knowledge/databases)

- [Stream MySQL backup directly to S3 bucket](https://rocketeersapp.com/knowledge/stream-mysql-backup-s3-bucket)
- [Importing database in MySQL using command line](https://rocketeersapp.com/knowledge/import-database-mysql-command-line)
- [Export MySQL database using command line](https://rocketeersapp.com/knowledge/export-database-mysql-command-line)
- [How to upgrade MySQL 5.7 to 8.0 on Ubuntu](https://rocketeersapp.com/knowledge/upgrade-mysql-5-7-to-8-0-ubuntu)
- [Backup MySQL databases in separate files](https://rocketeersapp.com/knowledge/backup-mysql-databases-separate-files)
- [Backup MySQL databases in single file](https://rocketeersapp.com/knowledge/backup-mysql-databases-single-file)

 [View all 20 articles →](https://rocketeersapp.com/knowledge/databases)
