MySQL : Backup / Dump MySQL Database in Windows and Ubuntu

MySQL is opensource database commonly used in many application. phpMyAdmin is the web based interface available for do our operations in MySQL. We can run commands to take database backup without phpMyAdmin interface.

Syntax:
Local Server :

> mysqldump -u DB_USER_NAME -p DATABASE_NAME > DUMP_FILE_NAME.sql

Remote Server :

> mysqldump -u DB_USER_NAME -h HOST_NAME -p DATABASE_NAME > DUMP_FILE_NAME.sql

Usage
Type 1 : MySQL is in Local Server

1. Open Terminal or Command Prompt.
    Windows : Run (Ctrl+R) -> cmd(Type)
    Ubuntu : Terminal(Ctrl+T)

2. Type Below command in Terminal / Command Prompt

> mysqldump -u codeexpertz -p db_sample > db_sample_backup_16112016.sql

3. Typing above command asking password of Database, Please enter password and Type Enter

4. After few seconds Dump is saved in your Local folder. 


Type 2 : MySQL is in Remote Server

1. Open Terminal or Command Prompt.
    Windows : Run (Ctrl+R) -> cmd(Type)
    Ubuntu : Terminal(Ctrl+T)

2.a) In Ubuntu type below command in Terminal

> mysqldump -u codeexpertz -h 192.168.99.64 -p db_sample > db_sample_backup_16112016.sql

          (OR)

> ssh codeexpertz@example.com 
> mysqldump -u codeexpertz -p db_sample > db_sample_backup_16112016.sql

  b) In Windows below command in Command Terminal

> mysqldump -u codeexpertz -h 192.168.99.64 -p db_sample > db_sample_backup_16112016.sql

          (OR)
    i) Use Putty to login to Remote Server user server username and password
    ii) Type below command in putty   

> mysqldump -u codeexpertz -p db_sample > db_sample_backup_16112016.sql   

3. Typing above command asking password of Database, Please enter password and Type Enter

4. After few seconds Dump is saved in your Local folder. 


Note : Dump time is based on Database size.

Category: