Is it possible to pass a determined $MYSQL_ROOT_PASS to MySQL docker from outside docker? If so how?

So I’m writing an install script and because I haven’t been able to find a solid MySQL replacement on armfh (the db must be MySQL compatible), I’m using a community on that works, however it does not initiate the db as it should. it requires me to pass the following argument.

mysql -h"db" -u"root" -p"$MYSQL_ROOT_PASSWORD" "$MYSQL_DATABASE" < /docker-entrypoint-initdb.d/1_db.sql

From inside the docker. Problem is I want this to flow naturally as a smooth install script. I’ve tried using the following command to pass the document and get a password prompt:

docker exec -it db bash -c "mysql -h"db" -u"root" -p"$MYSQL_ROOT_PASSWORD" "$MYSQL_DATABASE" < /docker-entrypoint-initdb.d/1_db.sql"

If also tried:

docker exec -it db bash -c "mysql -h'db' -u'root' -p'$MYSQL_ROOT_PASSWORD' '$MYSQL_DATABASE' < /docker-entrypoint-initdb.d/1_db.sql

FwIW: I used the MYSQL_ROOT_PASSWORD=$(cat /dev/urandom | tr -dc 'a-zA-Z0-9' | fold -w 64 | head -n 1) to define the password. And if I manually enter the docker send command 1 (in quotations) the db initiates.

So to summarize my question: Is it possible to pass a command like the above to activate the 1_db.sql file from outside docker?

Any help would be amazing! Thanks in advance!

Source: StackOverflow