---
title: 'Restore MariaDb in Docker'
url: 'https://rizzato-souel.fr/restore-mariadb-in-docker'
markdown: 'https://rizzato-souel.fr/restore-mariadb-in-docker.md'
date: '2024-12-01'
description: 'How to test your Mariadb backup with Docker An easy way to test your backup is creating a new instance : docker run -d --rm --name mariadb-test --env MARIADB_ROOT_PASSWORD=root-pw \ --env MARIADB_USER=user1 --env MARIADB_PASSWORD=passwd1 -p 3306:3306 mariadb Restore your backup: docker exec -i …'
taxonomy:
  tag:
    - docker
    - selfhosting
    - mariadb
---

# Restore MariaDb in Docker

## [Restore MariaDb in Docker](https://rizzato-souel.fr/restore-mariadb-in-docker)

    1st Dec 2024   [docker](https://rizzato-souel.fr/tag:docker#body-wrapper) [selfhosting](https://rizzato-souel.fr/tag:selfhosting#body-wrapper) [mariadb](https://rizzato-souel.fr/tag:mariadb#body-wrapper)  

### How to test your Mariadb backup with Docker

An easy way to test your backup is creating a new instance :

```
docker run -d --rm --name mariadb-test --env MARIADB_ROOT_PASSWORD=root-pw \ 

 --env MARIADB_USER=user1 --env MARIADB_PASSWORD=passwd1 -p 3306:3306 mariadb
```

Restore your backup:

```
docker exec -i mariadb-test mariadb --password=root-pw -uroot  < backup_yyyymmdd.sql
```

Grant access to the user on your databases:

```
docker exec -it mariadb-test mariadb --password=root-pw -uroot
```

```sql
GRANT ALL PRIVILEGES ON *.* to 'user1'@localhost IDENTIFIED by 'passwd1';
flush privileges;
```

You should now connect as previously:

```
docker exec -it mariadb-test mariadb --password=passwd1 -uuser1
```

 [ Previous Post](https://rizzato-souel.fr/backup-mariadb-in-docker-using-cron) [Next Post ](https://rizzato-souel.fr/quick-creation-of-vpn-with-wireguard-server-to-server)

---

## Navigation

- Parent: [Blog](https://rizzato-souel.fr/index.md)
- Previous: [Quick creation of VPN with WireGuard Server to Server](https://rizzato-souel.fr/quick-creation-of-vpn-with-wireguard-server-to-server.md)
- Next: [Backup MariaDb in Docker using cron](https://rizzato-souel.fr/backup-mariadb-in-docker-using-cron.md)
