Facebook Twitter Instagram
    TecAdmin
    • Home
    • Ubuntu 20.04
      • Upgrade Ubuntu
      • Install Java
      • Install Node.js
      • Install Docker
      • Install LAMP Stack
    • Tutorials
      • AWS
      • Shell Scripting
      • Docker
      • Git
      • MongoDB
    • FeedBack
    • Submit Article
    • About Us
    Facebook Twitter Instagram
    TecAdmin
    Home»Databases»How to Rename MySQL Database

    How to Rename MySQL Database

    RahulBy RahulJuly 25, 20213 Mins ReadUpdated:July 26, 2021

    While working with the databases, many times you may need to rename a database. For security purposes, MySQL had dropped the direct command to rename a database from MySQL 5.1.23. So there is no direct command to the T-SQL statement available for renaming a database in MySQL server.

    You can follow one of the below instructions to rename a MySQL database with the help of cPanel, phpMyAdmin, or command line as per the availability. After renaming the database, remember that you need to reconfigure the permission on the new database for the users.

    In this tutorial, you will find three methods to rename a MySQL database.

    Method 1 – Rename MySQL Database with Command Line

    As you know that there is no direct command or SQL statement available for renaming the database in the MySQL server. But you can still change the database name using backup and restore options.

    1. First, take a backup of current database:
      mysqldump -u root -p old_db > old_db.sql 
      
    2. Then create a new database with the desired name in the MySQL server.
      mysqladmin -u root -p create new_db 
      
    3. Finally restore the backup taken above to the newly created database.
      mysql -u root -p new_db < old_db.sql 
      

    You have a new database with a new name. Verify the new database and make sure that restore completely and functioning properly.

    Method 2 - Rename MySQL Database with phpMyAdmin

    phpMyAdmin is the most popular web application used for managing MySQL databases. It provides you an option to rename the database in the MySQL server.

    1. Log in to the phpMyAdmin
    2. Select database in the left sidebar.
    3. Click the "Operations" tab.
    4. Type a new database name in the field “Rename database to:” and click Go.

      rename database in phpMyadmin

    5. On confirmation dialog, click OK.
    6. Confirm to rename database in phpMyAdmin

    All done. Here phpMyAdmin will create a new database with a new name and copy all content from the old one. After that drop the old database.

    Method 3 - Rename MySQL Database with cPanel

    cPanel is a web-based control panel for the CentOS and Redhat Linux systems. It is popular among shared hosting providers. You can easily rename a MySQL database with the help of cPanel.

    The cPanel offers the easiest way to rename a MySQL database.

    1. Log in to the cPanel.
    2. Go to the Databases section and click MySQL Databases.

      Go to MySQL databases

    3. Scroll down to this page, you will find the list of databases under the Current Databases section.
    4. Click the "rename" button in front of the database to be rename.

      Select rename database

    5. Provide a new database name and click Proceed.

      Rename MySQL database in cPanel

    That's it. You have successfully renamed a MySQL database.

    Conclusion

    This guide helps you to understand how to rename MySQL databases. You will have to reconfigure the user permissions since the database has been renamed.

    command-line cpanel database MySQL phpmyadmin
    Share. Facebook Twitter Pinterest LinkedIn Tumblr Email WhatsApp
    Previous ArticleHow To Secure SSH Server
    Next Article How to Use SSH Config File

    Related Posts

    Backup MySQL Databases to Amazon S3 (Shell Script)

    Updated:May 28, 20222 Mins Read

    How to Install MariaDB on Ubuntu 22.04

    Updated:May 28, 20222 Mins Read

    How To Install Linux, Nginx, MySQL, & PHP (LEMP Stack) on Ubuntu 22.04

    Updated:April 7, 20227 Mins Read

    How To Install MySQL Server on Ubuntu 22.04

    Updated:April 6, 20224 Mins Read

    How to Install Apache, MySQL, PHP (LAMP Stack) on Ubuntu 22.04

    Updated:June 28, 20225 Mins Read

    How To Install MariaDB on Debian 11

    4 Mins Read

    Leave A Reply Cancel Reply

    Recent Posts
    • How to run “npm start” through docker
    • Filesystem Hierarchy Structure (FHS) in Linux
    • How to accept user input in Python
    • What is difference between var, let and const in JavaScript?
    • What is CPU? – Definition, Types and Parts
    Facebook Twitter Instagram Pinterest
    © 2022 Tecadmin.net. All Rights Reserved | Terms  | Privacy Policy

    Type above and press Enter to search. Press Esc to cancel.