"Error creating foreign key (check data types)…" but they do match…
It was a bug with phpmyadmin.

When you create a new constraint you usually are allowed to leave its name field blank, and it fills it for you.

This time, for some still unknown reason, this didn't work and gave this unrelated error.

Filling the name field did the trick, and allowed me to create the constraint.