Ubuntu comes with a nice command called ‘mysqldump’. We are going to use the command as shown below to backup our database. Replace the username, database_name and backup_file_name wit the correct values. Also, enter your database password when prompted to do so:
mysqldump -u username -p database_name > backup_file_name.sql