How best to populate a MySQL database?

Hello,

I have a MySQL database I’ve got running in a container as part of a docker-compose file with a REST service. What I’m wondering is how best to populate that database since it’s just an empty MySQL default instance.

Since I have a REST service running in another container, maybe populating the database programmatically from the service would be the best route?

Looking for suggestions from the community here. :slight_smile:

Thanks for any suggestions.

    volumes:
      - ./dump.sql:/docker-entrypoint-initdb.d/dump.sql

The image runs every SQL file in that dir, at creation point :slight_smile:

1 Like

Thank you very much. This worked perfectly. :slight_smile:

A note: it is going to run it in alphanumeric order. I recommend that you prefix the sql files with a number, for example like this:
1_Create_Database.sql
2_Create_Tables.sql
3_PopulateTestData.sql

and so on.

Thanks for that information. I’ll do that.