Last Updated: 28 May, 2023
In MySQL, there is no direct command to rename a database. However, we can achieve the renaming of a database by following these steps:
CREATE DATABASE new_database;
mysqldump -u <username> -p <old_database> | mysql -u <username> -p <new_database>
Replace <username>, <old_database>, and <new_database> with the appropriate values.
DROP DATABASE old_database;
Note: Be cautious when executing this command, as it permanently deletes the old database and its data.
By following these steps, you effectively rename the database by creating a new one with the desired name and transferring the data from the old database to the new database.
That's all, guys. I hope this MySQL article is helpful for you.
Happy Learning... 😀
feedback@javabytechie.com