Home:ALL Converter>How to import an existing MySQL-Database in my MySQL-Docker Container?

How to import an existing MySQL-Database in my MySQL-Docker Container?

Ask Time:2018-06-20T20:32:24         Author:banana-joe

Json Formatter

I have created a docker container based on the official image of MySQL from Docker Hub. It works fine, but I have some troubles with the database import.

My file with the SQL-Instructions is already stored in the folder /docker-entrypoint-initdb.d of my container, but it doesn't work! I have copied my sql-import.sql to /var/lib/docker/volumes/mysql-dump/_data, but I can only see the name of my database when I call "SHOW DATABASES;" within my container. There is no table available when I call "SHOW TABLES FROM myDB;". What can I do to import the content of my MySQL Database?

Here is my Dockerfile:

FROM mysql:5.7
ADD ./init-scripts/*.sql /docker-entrypoint-initdb.d/
ADD ./config/my.cnf /root/
RUN cd /root/ && \
chmod 0600 my.cnf && \
mv my.cnf .my.cnf

ENV MYSQL_DATABASE=regex
ENV MYSQL_ROOT_PASSWORD=mypassword

EXPOSE 3306

MySQL View in the MySQL-Container

Author:banana-joe,eproduced under the CC 4.0 BY-SA copyright license with a link to the original source and this disclaimer.
Link to original article:https://stackoverflow.com/questions/50948372/how-to-import-an-existing-mysql-database-in-my-mysql-docker-container
yy