Magento database is normally generated by the proper command on a new installation. But if you want to use an existing one,
you need to import it. There is not yet any script that automatically import it. So you need to do it manually. To have
your dump accessible from within the container. You need to place your dump in data folder. It is mounted in /data/
folder.
Enter in your container :
docker exec -it my_magento_mysql bash
Once in the container, you can import your dump using the following command :
mysql -u root -p${MYSQL_ROOT_PASSWORD} ${MYSQL_DATABASE} < /data/<mydump>.sql
If you get database from different environment, you need to change the domain in the database. You can do it with the following command :
bin/updatecoreconfig
This command is made to create a copy of the file update-core-config.sql.template and replace the domain in it. Then it injects the sql script in the database. It's handy and permits to run it again if you need to change the domain. It also sets the correct data for elasticsearch instances and modify some entries regarding development.
If for some reason, this command does not work, you can do it manually with the following commands :
First, you need to enter in your container using the same command as previously stated. Then, you need to execute the following command :
cp /data/update-core-config.sql.template /data/update-core-config.sql && sed -i "s/{DOMAIN}/${NGINX_HOST}/" /data/update-core-config.sql
Then inject your modified sql script in database using :
mysql -u root -p${MYSQL_ROOT_PASSWORD} ${MYSQL_DATABASE} < /data/update-core-config.sql
Database can be accessed in PHP Storm with proper configuration. The host will be 172.28..5 when user and password will be the ones that you set. You can also use phpmyadmin (see below).