Home » Backup MySQL Database In Terminal

Import MySql database records into an .sql file from the terminal using the MySql command mysqldump, it is a quick and easy way to backup MySql database records.


  • MySQL
  • Command line terminal

How to manually backup a MySQL database.

mysqldump -uNAME -pPASSWORD DATABASE > database.sql


  • NAME = the user name who has access to the database.
  • PASSWORD = the password of the user name.
  • DATABASE = the name of the database to backup.
  • database.sql = the sql file where the records will be saved.

Other Examples.

Do not include the password on the command, and enter only when prompted.

mysqldump -uNAME -p DATABASE > database.sql

Import specific TABLE.

mysqldump -uNAME -pPASSWORD DATABASE TABLE > database.sql

Import multiple TABLEs.

mysqldump -uNAME -pPASSWORD DATABASE TABLE1 TABLE2 TABLE3 > database.sql

Specifically save to linux home directory.

mysqldump -uNAME -pPASSWORD DATABASE > /home/database.sql

Specifically save to windows drive D.

mysqldump -uNAME -pPASSWORD DATABASE > D:\database.sql


  • If the path where the file is to be saved was not specified, the .sql file (database.sql) will be saved on the same location where the command is executed.
  • The same command can also be executed on windows command line.





One response to “Backup MySQL Database In Terminal”

  1. […] Backup MySQL Database In Terminal […]

Leave a Reply

Your email address will not be published. Required fields are marked *