MySQL: Duplicate a MySQL database
First, create an empty database, say new-db for example.
create database new_db;
Then on the command line, using the mysqldump tool to dump the database you want to copy old_db, pipe it to the next command mysql to import the database into the new database new_db.
nohup mysqldump -u admin old_db | mysql -u admin new_db &
nohup means no hang up to make sure the database duplcation process don’t hang up in the middle. If the database is large, it might take a while up to hours or even days.
mysqldump is the mysql admin tool to dump out a database.
-u is the option flag to specify the mysql user name.
admin is the mysql username
old_db is the old database you want to make a copy of.
| is a unix pipe command that takes the output from the comman before it and use it as input to the command after it.
new_db is the new database name.
& at the end of the comman line puts the process in the background.
Search within Codexpedia
Search the entire web