Docker capsule import failure due to missing utf8mb4_0900_ai_ci collation on MariaDB

MariaDB / MySQL collation problem. I thought I’d mention that I ran into an issue with importing a MySQL 8.0.1 dump file into a MariaDB instance due to incompatible collation settings between the two. MariaDB does not support the utf8mb4_0900_ai_ci collation that MySQL sets tables to use by default. The easy development dockers run on MariaDB but a lot of production instances use the AWS MySQL versions.

I was working with a docker capsule so I had to extract the capsule contents and work with the raw backup.sql before being able to import the file into OpenEMR. I use the utf8mb4_unicode_520_ci collation but apparently newer versions of MariaDB can use uca1400_as_ci also.

I use sed to do the replacement, it did take up a bunch of temporary file space (about 20GB for a 7GB db dump). But I was able to then import the file.

sed -i 's/utf8mb4_0900_ai_ci/utf8mb4_unicode_520_ci/g' backup.sql

There may be an already built openemr utility to handle all of this but couldn’t find it at the time. If there isn’t we may want to build this into our openemr-cmd capsule import process so we can work across db products.

However, if more and more of these incompatibilities crop up, it may be time to pick a specific MySQL flavor instead of supporting both MySQL and MariaDB.

1 Like

Hi,

setup.php only allows selection of several collations (default is utf8mb4_general_ci):
openemr/setup.php at master · openemr/openemr · GitHub

and the autoscript installer wiil use utf8mb4_general_ci (and the aws mysql versions should be using this for their installation unless I am incorrect @jesdynf )

These kind of things can happen when users create their own database in mysql rather than openemr doing it (and in some cases can end up with hybrid encoding/collation).