Blog Bustle 20/02/2020
We can copy mysql database to another database which is on same server or another server. It is easy and fast process.
Lets know what are the steps of mysql copy database to another database
Step 1: Take backup of database whom do you want to copy
Step 2: Create new database in which you want to copy
Step 3: Import backup file into new database
for example, we have student database and we want to copy student database into college database. so first we take backup of student database. We know, we use mysql dump tool for database backup.
mysqldump -u [user_name] -p [user_password] [database_name] > [dump_file_name.sql]
I am using local server, so database backup command will be
mysqldump -u root -p student > d:\student.sql
in my case username is root and password is empty.
create database database_name;
now i am going to create college database in mysql server and command line will be
create database college;
so our new database is ready and we have taken backup of student database and it's time to import student.sql file into college database.
mysql -u [user_name] -p [user_password] [database_name] < [dump_file_name.sql]
We will import student.sql file into college database and import database mysql command line will be
mysql -u root -p college < d:\student.sql
So we saw mysql copy database is easy, simple and fast process.
Mysql copy database is very useful when we are working on any project and continue we are doing some changes in current database so we have to keep database backup. We also use this database backup for local server testing.