This article explains how to rename 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 Webhost.Berlin account includes cPanel access.
If your Webhost.Berlin account includes cPanel access, you can use phpMyAdmin to quickly and easily rename a MySQL database. To do this, follow these steps:
If your Webhost.Berlin account does not include cPanel, you can rename a MySQL database manually from the command line. To do this, follow these steps:
mysql -u USERNAME -p -e "CREATE DATABASE NEW_DBNAME"
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:
mysqldump -u USERNAME -p OLD_DBNAME > dbexport.sql
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:
mysql -u USERNAME -p NEW_DBNAME < dbexport.sql
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:
mysql -u USERNAME -p -e "DROP DATABASE OLD_DBNAME"