Create a MySQL Docker container

docker run --name my-container-name -e MYSQL_ROOT_PASSWORD=my-secret-pw -d mysql

Login to Docker container bash / terminal

docker exec -it mysql bash

Create MySQL database in Docker

In order to create the database you'll first need to login to bash / terminal for the MySQL container as shown above. The next step is to login to MySQL:

mysql -u root -p

Run the following command to create the database:

create database DATABASE_NAME;

To backup / dump a MySQL database from a Docker container:

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

To import a MySQL database:

cat backup.sql | docker exec -i CONTAINER /usr/bin/mysql -u root --password=root DATABASE