Backup and restore a database with mysqldump

To backup your database using mysqldump simply type:

mysqldump -p -u[username] [database] > [filename].sql

where:

  • username = the mysql username (with the appropriate rights for this database [of course])
  • database = the name of the databse you want to backup
  • filename = the name of the file you want the dump to be saved as

To restore a backup you could type:

mysql -p -u[user] [database] < [filename].sql