AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |
Back to Blog
Rename database in mysql phpmyadmin1/17/2024 But note that this method works well only with small databases as it creates a problem if the data is sufficiently big and large during backup and restoration. Then restore the backup file with the new name of the database that you wish to have. One of the methods that can be followed to rename the database for small databases easily and effectively is to dump the database to create a backup file. Then you can execute the DROP DATABASE statement in the following manner:Įxplanation: where old_Name_Of_DB is the name of your old database that existed, and you wanted to rename. But before that, you can ensure all your tables are present in the new database, and the old one is empty to avoid data loss. Step 3: The last thing to do is drop the old existing database that you wanted to rename. To accomplish this, you can follow these steps.Ĭode: RENAME TABLE old_Name_Of_DB.presentTable1 TO new_Name_Of_DB.presentTable1, old_Name_Of_DB.presentTable2 TO new_Name_Of_DB.presentTable2 If we want to rename a table and move it to a new database, we can easily do so by using the new database name, followed by a dot and the table name. When referring to a table, we typically use the database name followed by a dot and the table name. Step 2: The next step is to rename the names of tables of the existing database. For that, you can execute the following statement.Įxplanation: where new_Name_Of_DB is the name of the new database. Step 1: The first step we need to perform is to create a new database with the name we want to rename the existing database. Let us see each of the methods in detail one by one: 1. Just close your MySQL server and then rename the directory of your database, i.e., the folder of the database then that will automatically lead to a changed database name with the changed directory name. If all the tables in your existing database are of type MyISAM, then you can use one trick. Write the script in case you use the Linux platform containing the code to get all the tables from the database and rename all the tables to the new database name. Rename all the old database tables to new database names and then drop the old database.ĭump the existing database to generate backup and restore the backup with a new name of the database. Below is a list of some of the methods that can be followed to rename the database in the latest versions of MySQL:Ĭreate a new database with the name you wish to change to the older database. However, this method is not supported in the latest versions of MySQL for security reasons. Or ALTER DATABASE existing_DB_name MODIFY NAME = name_Of_new_DB Methods of Renaming the Database RENAME DATABASE existing_DB_name TO name_Of_new_DB
0 Comments
Read More
Leave a Reply. |