How to export MySQL Database using MySQLDump

In this Post, we will see how to export MySQL database using MySQLDump through command line.

 

Steps to export MySQL database using MySQLDump

 

  • Before performing below steps please make sure you have put entry of your MySQL in your System path variable. If you have configured MySQLPath then you can directly call mysqldump command, otherwise you have to go to location of your installed MySQL.

 

  • Open command line interpreter with “Run as administrator“. Make sure you open cmd as administrator, otherwise mysqldump will throw Access Denied error.

 

open-cmd-as-administrator

 

  • You can type below MySQLDump command to take the backup of your database.

 

mysqldump -u username -p db_name > your_choice_dbname.sql

 

here

  • mysqldump is keyword.
  • username is the username of the mysql
  • db_name is the name of the database you want to export.
  • your_choice_dbname is any name of your choice.

 

  • In our case, username is root. db_name is employee. your_choice_dbname is exportEmp, so we will execute following command
mysqldump -u root -p employee > exportEmp.sql

 

After executing this command, MySQL will ask for password. put the password and your database will be exported to in your MySQL bin folder

 

 export-mysql-database-with-mysqldump-command

 

  • If you want to export MySQL database at specific location then you can also do that.

 

mysqldump -u root -p employee > C:\demo\ExportEmp.sql

 

Now ExportEmp.sql will be exported to the location c:\demo\

 

export-mysql-database-at-specific-location-using-mysqldump

 

So finally we have exported the MySQL database using mysqldump.