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 A2 Hosting account includes cPanel access.
If your A2 Hosting account includes cPanel access, you can use cPanel to quickly and easily rename a MySQL database. To do this, follow these steps:
The Rename Database dialog box appears.
In the New name text box, type the new name for the database:
If your A2 Hosting 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 --routines -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"
Subscribe to receive weekly cutting edge tips, strategies, and news you need to grow your web business.
No charge. Unsubscribe anytime.
Did you find this article helpful? Then you'll love our support. Experience the A2 Hosting difference today and get a pre-secured, pre-optimized website. Check out our web hosting plans today.
We use cookies to personalize the website for you and to analyze the use of our website. You consent to this by clicking on "I consent" or by continuing your use of this website. Further information about cookies can be found in our Privacy Policy.