How to export mysql or mariadb data from docker

List running dockers that running with mysql or mariadb

[email protected] ~ % docker ps
CONTAINER ID   IMAGE       COMMAND                  CREATED        STATUS          PORTS                     NAMES
7e49a319857c   mariadb     "docker-entrypoint.s…"   24 hours ago   Up 21 minutes   0.0.0.0:54482->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

Tags:

Leave a Comment

Your email address will not be published.

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