# MySQL/MariaDB

# Create a dump file

If this is running on your local machine, do this. You will need to be inside the container or, in a directory/location that is local to the mysql/mariadb database.

```
mysqldump --single-transaction --default-character-set=utf8mb4 -h [server] -u [username] -p[password] [db_name] > nextcloud-sqlbkp_`date +"%Y%m%d"`.bak
```

If it is running in a container, you will need to run this command in that container.

```bash
docker exec [CONTAINER_NAME_OR_ID] /usr/bin/mysqldump -u [USERNAME] --password=[PASSWORD] [DATABASE_NAME] > [BACKUP_FILE.sql]
```

<span>Replace:</span>

- <span>`[CONTAINER_NAME_OR_ID]`</span><span> with the name or ID of the Docker container running MySQL</span>
- <span>`[USERNAME]`</span><span> with the MySQL username</span>
- <span>`[PASSWORD]`</span><span> with the MySQL user's password</span>
- <span>`[DATABASE_NAME]`</span><span> with the name of the database to dump</span>
- <span>`[BACKUP_FILE.sql]`</span><span> with the desired name for the SQL backup file</span>


##### <span>Note:</span>

<span>The typical process of creating a database dump requires connecting to the running database server and executing a command like `mysqldump` or `pg_dump` to export the database data to a SQL file. However, without a running database instance, these commands cannot be executed.</span>