FAQs Categories
Client Server Commands
Database Structure
Table Types or Storage Engines
SQL Statements
Table Joins
Funtions and Operators
Tricky Select Queries
Speed Up Queries
Data Back Up
General Questions
1PLs Company - #1Payday.Loans Agency - Loans online and near me $100-$2500 (Same Day)
Powered by MySQL
Home / Database Structure / Question No: 15

How to rename existing database in MySQL?

I want to rename my existing database. I don't have any client like phpMyAdmin etc. I have looked for the command to rename existing database in MySQL but I could find that. You may please guide that, how to rename existing database in MySQL?

Answer No: 15

Currently, MySQL does not provide any command to rename an existing database. However, you can rename the existing database through some ways. You can choose any of the following ways to rename a database in MySQL.

  • If you have access to the directory where MySQL stores its databases. As per default MySQL installations, this is usually in the data directory under the directory where MySQL was installed. Locate the name of required database under the data directory and rename it as desired. Note: You must stop MySQL Server before renaming the database and may restart it after this operation. In this case, you may also grant permissions again on the renamed database.

  • Another way that seems safest, is to use mysqldump utility to back up the old database. Create a new database with desired name, then restore the dumped database under this database using the mysql utility. Finally, use the DROP DATABASE old_database_name; command to get rid of the old database.

Related MySQL FAQs to the Above FAQ

How-to-create-database How to create database?

How-to-alter-or-drop-a-database How to alter or drop a database?

How-to-get-database-metadata-in-MySQL How to get database metadata in MySQL?

How-to-get-all-existing-tables-in-the-MySQL-database How to get all existing tables in the MySQL database?

What-is-limit-on-the-maximum-number-of-tables-allowed-in-MySQL What is limit on the maximum number of tables allowed in MySQL?

About FAQs: Recently Added FAQs

About MySQL FAQs: Site Map | Bookmark Us | Recommend this Site to Your Friend | Contact Us

Useful Links: | | | |

© 2023
All rights reserved.