I am a DDEV and Docker newbie but have successfully setup a local web host with DDEV on MacOS. I understand that docker containers are built from scratch each time and I put my Apache configs into a .htaccess
file to keep them persistent. I am looking for a way to make persistent configurations to the Maria DB instance. I am use to using the mysql/conf.d/myconf.cnf
file to define configs but I am unsure of the "proper" way to do it in DDEV. Any help or suggestions would be great.
I have accessed and looked in my project-db dir /etc/mysql/conf.d/
but I assume putting a myconf.cnf
file there will get blown away on project restart. I have Googled a bit and seen that Docker can mount external dirs and files to a container, but I am not even sure that this is the right path for DDEV.
2
Answers
My problem was that I was migrating from a very old DB. The difference was that the DDEV Maria DB had the
STRICT_TRANS_TABLES
sql_mode
, whereas the old DB did not. Many fields in the old tables were defined as NOT NULL, but had no default value, that was causing SQL errors.Rather than attempting to change the DDEV DB
sql_mode
, I opted to update the DB fields with proper definitions, so no need to mess with the.ddev/mysql/*.cnf
file.If you want to add extra database configuration with DDEV you do it in a
.ddev/mysql/*.cnf
file. Just create the file and add the configuration andddev restart
.It’s unusual that people need to do that very much. The docs are at https://ddev.readthedocs.io/en/stable/users/extend/customization-extendibility/#custom-mysqlmariadb-configuration-mycnf