Backup and Restore Database of MySQL Using mysqldump

It is a powerful command which creates dump or backup of one or more Mysql Databases, which can also be transferred to another SQL Server.

Monu Kumar Modi
1 min readNov 23, 2019

--

It creates a .sql file of the database which can be restored in any SQL server.

Commands for the backup and restore MySQL database

Backup Database:

Syntax: mysqldump -u[user] -p[password] [dbname] > [backfile.sql]

Here user is “root” for my all examples.

1.For Single Database backup (Database is an employee)

Example: mysqldump -u root -p employee > employee.sql

2.For more than one Database backup (Databases are employee and customer)

Example: mysqldump -u root -p — databases employee customer > database.sql

3.For all Database backup

Example: mysqldump -u root -p — all-databases > alldatabase.sql

Restore Database:

Syntax: mysql -u[user] -p[password] [dbname] < backupfile.sql

Restore “employee.sql” in employee database.

Example: mysql -u root — p employee < employee.sql

Refrences:

https://www.w3schools.com/sql/

--

--

Monu Kumar Modi
Monu Kumar Modi

Written by Monu Kumar Modi

I share insights on JavaScript, React, Node, and coding, solving challenges and simplifying tech. Open to opportunities! #JavaScript | linkedin.com/in/monukmodi

No responses yet