This tutorial will show you how to copy or clone an entire database, including all the data, indexes, and keys.
This tutorial assumes that you meet the following conditions:
- You have access to a database, and
- Shell Access to your server.
How to Export A Database
For illustration purposes, I will use the Employees Sample Database provided in the resource below:
https://dev.mysql.com/doc/index-other.html
To export a database, use the mysqldump tool as:
How to Restore a Database
Restoring a database is as simple as reversing the redirection symbol. For example, to restore the employees’ database from the resource provided above, use the command:
This will import the exported database with output as shown below:
INFO
CREATING DATABASE STRUCTURE
INFO
storage engine: InnoDB
INFO
LOADING departments
INFO
LOADING employees
INFO
LOADING dept_emp
INFO
LOADING dept_manager
INFO
LOADING titles
INFO
LOADING salaries
data_load_time_diff
00:00:38
Conclusion
This tutorial has shown you how to use MySQLdump to export databases from one server to another or the same server.