See this screenshot from IntellIj’s PHPStorm Database tool: PHPStorm DB settingsįrom my experience these clients are very good to check data but not so good for import, at least I had rather poor experience in the PHPStorm DB Tool. container/mysql/my.cnf:/etc/mysql/conf.d/z_my.cnf Using a mysql GUI client on the host and connect to the DB in the Docker containerįor this approach you just need to open a port in the database container to the outside and use this port with localhost in the settings of your database client. To import data go to the import tab and upload the dump file. Then you can just open in the browser and log into to Phpmyadmin. If the above is too consolish then you also can just add a phpmyaadmin container in your docker-compose setup and administer the database with a GUI from the browser. This will execute the application image and import the data with the mysql client which connects to the host mysql which is the linked mysql container. With this one liner you can import a SQL dump from a docker image that has a MySql/MariaDB client installed and are linked to the DB container: docker-compose exec my-app bash -c "mysql -u root -h mysql -password=root database < database_dump.sql" Code language: JavaScript ( javascript ) Using mysql client from commandline with docker-compose exec You can clear all volumes of your docker-compose setup with (caution: this will clear all volumes, not just the database volume):ĭocker-compose down -v 2. clearing the volume, otherwise the import will not start: Note: if there is already data in the database you need to clear the data first by f.e. 15:40:16+00:00 : /usr/local/bin/docker-entrypoint.sh: running /docker-entrypoint-initdb.d/database_dump.sql You will see something like this in your docker-compose logs: Im trying to connect to a PostgreSQL container with DataGrip in Linux. On next docker-compose up the data will be imported in your empty database. database_dump.sql:/docker-entrypoint-initdb.d/datadump.sql So let’s add this volume to our docker-compose.yaml So all dumps that are found in the /docker-entrypoint-initdb.d directory of the image will be imported unless the database already contains data. You can easily populate your mysql services by mounting a SQL dump into that directory Files will be executed in alphabetical order. sql.gz that are found in /docker-entrypoint-initdb.d. These have builtin import mechanism to import data.įurthermore, it will execute files with extensions. This applies to both official Mysql and MariaDB official images. Using a mysql GUI client on the host and connect to the DB in the Docker container.Using phpmyadmin in docker-compose setup.Using mysql client from commandline with docker-compose exec.There are several ways to import the data in your docker-compose setup. Having a docker-compose setup which involves a Database like Mysql or MariaDB, then at some point you might want to import data into those Databases.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |