I am currently running a Java Spring application using TestContainers to manage my datasources. I am having issues setting global variables for my MySQL instance on Docker during initialization of the docker instance.
I've tried a few things.
TestContainers has a method execInContainer
which takes a string of commands.
container.execInContainer("mysqld", "--character_set_server=utf8");
In addition, you can also run an init script using
.withInitScript("mysql_test_init.sql");
SET @@global.character_set_client = 'utf8';
SET @@global.character_set_server = 'utf8';
Using execInContainer
seems to do nothing and does not change the variable(s) in MySQL.
Using the script fails due to Docker using a non-root user to make changes.
Access denied for user 'test'@'%' (using password: YES)
Is there a way I can easily change/configure the global variables of MySQL. Am I doing something wrong?
Some parameters I would like to change:
character_set_client
character_set_connection
Thank you.