---
title: "Backup / Export a Database from SSH"
description: "In this tutorial we will show you how to export a database from SSH. This is useful for many things such as when you are moving your site, since it exports the entire database, or before you attempt..."
url: https://www.inmotionhosting.com/support/website/backup-database-ssh/
date: 2013-01-09
modified: 2021-08-16
author: "InMotion Hosting Contributor"
categories: ["Backups and Restorations", "Website", "Working with Databases"]
type: post
lang: en
---

# Backup / Export a Database from SSH

In this tutorial we will show you how to** export a database from SSH**. This is useful for many things such as when you are moving your site, since it exports the entire database, or before you attempt to upgrade a website, since it is essentially a **backup** of the database.  

![How to Create a Backup Of the Database From SSH](https://i.ytimg.com/vi_webp/yo_dnack-cY/maxresdefault.webp)

*Don’t have time to read the article. Watch our walk-through video.*

## Generate a Database Backup

1. Connect to your server via [SSH](/support/server/ssh/how-to-login-ssh/).
2. In the command line enter the following code: mysqldump -u dbusername -p databasename > nameofdbbackup.sql --no-tablespaces Be sure to replace:*dbusername* = with the database username for the database you want to export.*databasename* = with the name of the database you want to export.*nameofdbbackup* = enter a name for the exported database.
3. Hit the **Enter** key and it will ask you for your password. Type your password and hit the **Enter** key again, it will begin exporting, this may take some time to complete, depending how large your database is. Your SSH client will take you to a new line when this process completes.The database will now be available for download in your home directory.

 
Congratulations, now you know how to Export / Backup your database from SSH!
