Setting up a MySQL database
So far, we have come a long way and built a solid foundation for our RESTful application, though we must take a few more steps to finally be able to begin with development.
In this step, we will configure our MySQL database for our application and perform some alterations in our Docker MySQL container in order to make the data of our application persist in our database, even when we disconnect or stop our MySQL container.
Adding a storage folder
A local folder to store MySQL data is very important since our docker-compose.yml
file does not contain any volume that's been configured to store the data created in our database yet.
Remember, we are using Docker, and our MySQL container is based on an image of a database. This way, every time we finish the container process, our database is erased and the next time we start it, our database will be empty.
Open the docker-compose.yml
file and add - ./storage-db:/var/lib/mysql
right after the application volumes on the MySQL...