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 may be necessary during site development or when migrating data from one account or hosting provider to another. The method depends on whether your hosting account includes cPanel access.

Managed Accounts with cPanel
If your account includes cPanel, you can rename a MySQL database easily:

  1. Log in to cPanel.

  2. In the Databases section, click Manage My Databases (or MySQL Databases in cPanel version 118 or earlier).       cPanel - Databases - Manage My Databases icon

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

  4. In the Actions column, click RenamecPanel - MySQL Databases - Rename

  5. In the New name text box, type the new database name. cPanel - MySQL Databases - Rename Database dialog box

  6. Click Proceed. cPanel renames the database.

Unmanaged Accounts without cPanel
If your account does not include cPanel, you can rename a MySQL database from the command line:

  1. Log in to your server using SSH.

  2. Create a new database:

mysql -u username -p -e "CREATE DATABASE new_dbname"
  1. Export the old database to a file:

mysqldump --routines -u username -p old_dbname > dbexport.sql
  1. Import the data into the new database:

mysql -u username -p new_dbname < dbexport.sql
  1. (Optional) Delete the old database:

mysql -u username -p -e "DROP DATABASE old_dbname"

You can now use the new database new_dbname, which contains all tables and data from the old database.

Was this answer helpful? 0 Users Found This Useful (0 Votes)

Powered by WHMCompleteSolution