# Restore a MySQL backup

Download and restore a MySQL dump file to any MySQL database.

SimpleBackups stores MySQL backups as compressed `.sql.gz` files. You restore them using the `mysql` CLI client on any server with access to your target database.

**This will overwrite the target database:**
Restoring a backup replaces all data in the target database with the contents of the backup file. Confirm you are restoring to the correct database before proceeding.

## Download the backup file

1. Go to your backup page and open the **Logs** tab. Click the **(i)** icon next to the backup run you want to restore.

![The backup log entry with the info icon highlighted](https://simplebackups.com/docs/docs-assets/www-notion-so/1ae3ac7fdcd477023f5b.png)

2. In the modal that appears, click **Click to generate a signed download link** and copy the resulting URL.

**Info:**
If your backup produces multiple files (for example, when backing up all databases separately), each database has its own signed link. See [how to download individual files when backing up all databases](https://support.simplebackups.com/en/articles/6493010-how-to-download-individual-files-when-backing-up-all-databases) for details.

3. On your server, download the backup using the signed URL:

```bash
wget "PASTE_SIGNED_DOWNLOAD_LINK_HERE" -O mysql-backup.sql.gz
```

4. Extract the archive:

```bash
tar -xvf mysql-backup.sql.gz
```

This produces a single SQL file named `db-backup-XXX.sql` in the same directory.

## Restore the database

Run the `mysql` client to restore the dump into your target database:

```bash
mysql -u YOUR_DB_USERNAME -pYOUR_DB_PASSWORD < db-backup-XXX.sql
```

Replace `YOUR_DB_USERNAME` and `YOUR_DB_PASSWORD` with your database credentials, and `db-backup-XXX.sql` with the extracted filename.
