How to Rename MySQL Database
To change the name of a MySQL database, you can use the RENAME DATABASE statement. Here are the steps to change the database name:
- Firstly, make sure that no one is accessing or using the database that needs to be changed.
- Change the name of the database using the following syntax:
RENAME DATABASE old_database_name TO new_database_name;
For example, if you want to change the database named “old_db” to “new_db”, you can execute the following statement:
RENAME DATABASE old_db TO new_db;
- Please note that the RENAME DATABASE statement requires SUPER privileges to execute. Make sure you have enough permissions to perform this operation.
- After executing the above statement, the name of the database will be changed to the new name. You can use the new database name to access and manipulate the database.