How to export mysql or mariadb data from docker

List running dockers that running with mysql or mariadb

juzhax@Justins-MacBook-Air ~ % docker ps
CONTAINER ID   IMAGE       COMMAND                  CREATED        STATUS          PORTS                     NAMES
7e49a319857c   mariadb     "docker-entrypoint.s…"   24 hours ago   Up 21 minutes>3306/tcp   wp-env-mysql-1

Access CLI to mariadb container

docker exec -it 7e49a319857c /bin/bash

Dump data using mysqldump

mysqldump -uroot -p wordpress > /tmp/wordpress.sql

Then exit the CLI.

Copy the data from docker out

docker cp 7e49a319857c:/tmp/wordpress.sql ./wordpress.sql


Leave a Comment

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.