Skip to main content

How to create a database dump in Mysql

Points To Remember


  1. You can take dump of Mysql using mysqldump in windows, linux or ubuntu operating systems.
  2. You should reach to the location of mysql/bin in a windows platform to use mysqldump, you can use from any location in ubuntu and linux.

Taking dump of whole database

When you want to take the dump of the whole file, you can simply do it with the following command
mysqldump -u db_username -p database_name > path/dump.sql
Here the database_name is your database name and path is absolute path where you want to create dump.

Taking dump of a table

When you want to take the dump of a single table you can do this by the following command.
mysqldump -u db_username -p database_name tablename > path/dump.sql

Taking dump of a remote database

When you want to take a dump of a remote user you can do this by the following command.
mysqldump -u <db_username> -h <db_host> -p database_name > path/dump.sql

Taking dump of a remote database table

When you want to take the dump of a single table from a remote database you can use the following command
mysqldump -u <db_username> -h <db_host> -p database_name table_name > path/dump.s
How to restore the database from a dump file.

Comments