Can I run some MySQL setup via a CMD instruction?

I’m fairly new to Docker so bear with me if I’m thinking about this the wrong way.

Essentially what I want to do is build a Dockerfile that is based on MySQL AND runs some set up (table, user creation etc.)

My thinking was to use CMD, something like:

FROM mysql:5.7

Am I on the right lines? And if so, is there a way I could have the MySQL commands read from a text file (bundled, via COPY) rather than declare them within the Dockerfile?

Many thanks in advance!

Initializing a fresh instance
When a container is started for the first time, a new database with the specified name will be created and initialized with the provided configuration variables. Furthermore, it will execute files with extensions .sh, .sql and .sql.gz that are found in /docker-entrypoint-initdb.d. Files will be executed in alphabetical order. You can easily populate your mysql services by mounting a SQL dump into that directory and provide custom images with contributed data. SQL files will be imported by default to the database specified by the MYSQL_DATABASE variable.

Thank you - just what I needed.