For remote DB the local mariadb should have no effect. If kodi does not connect while network is up (you are connected via ssh) this is likely something different.
For complete debug logging insert
to your advancedsettings.xml and activate Database Component Logging in Kodi settings.
Reboot. When Kodi is hanging execute pastekodi via ssh and post the URL.