How to take backup of database in MYSQL using shell mode in cloud / linux terminal / windows command prompt for developers and administrator in cloud server

How to take backup of database in MYSQL using  shell mode in cloud / linux terminal / windows command prompt for developers and administrator in cloud server


The following points we are going to discuss


  • Why we need database backup?
  • What is the command used for database backup using shell/terminal/command prompt
  • Description of the syntax
  • How can we take the backup of database ?
  • How can we take the backup of multiple database ?



Today in the following post we are going to discuss how to take the mysqldump command , the need of database backup is very important as all the transaction or records related to the business will be stored in mysql. To take the backup of the database in command prompt and save it is very useful

Developer's might take the backup of the databse when they are going to do major changes in the structre

Why we need database backup?

Database backup is required when there is a crash in server, it can be easily restored

When there is a disater having backup it can be easily resotred

This acts as a extra layer of protection if any one of the developer/coder truncates the data of the table it can be easliy restored

If there are cross site injection , then the database can be restored completly

Natural disaster

if you want to reproduce the issue, you can take the copy of database backup and install in your local system/server and try to debug it . This will not affect the online transaction


What is the command used for database backup using shell/terminal/command prompt


mysqldump -u {userName} –p {password} {databaseName} > [dumpFileName.sql]


Description of the syntax


{userName} : The user name of the mysql server. If you are not aware check with the administrator

{password} : The password of the mysql server

{databaseName} : The database name of the mysql server 

{dumpFileName.sql} : File name you wish to take the backup. It can be anything

How can we take the backup of database ?

mysqldump -u root –p root testDatabase > [dumpOfTestDatabse.sql]


How can we take the backup of multiple database


 Sometimes there might be need to take the backup of mulitple databases. The below command can be used in your linux terminal or clould ssh to take the backup

mysqldump -u root –p root --databases testDatabase1 testDatabase2 > [dumpOfTestDatabse1TestDatabase2.sql]


backup mysql database ubuntu

backup mysql database command line windows

mysql backup database script

mysql backup database to file

mysql backup all databases

backup mysql database phpmyadmin

mysql dump

backup