Exporting data from MySQL docker container

A little late to answer but this command saved my day.

docker exec CONTAINER /usr/bin/mysqldump -u root --password=root DATABASE > backup.sql

Run Following command on terminal

docker exec CONTAINER_id /usr/bin/mysqldump -uusername --password=yourpassword databasename> backup.sql

Replace the

  1. CONTAINER_id. username, yourpassword

with specific to your configuration.

To get Container Id :

docker container ls

I realise that this is an old question, but for those stumbling across it now I put together a post about exporting and importing from mysql docker containers: https://medium.com/@tomsowerby/mysql-backup-and-restore-in-docker-fcc07137c757 It covers the "Using a password on the command line interface..." warning and how to bypass it.