So... You're telling us you need local
sudo mysql ... because the remote MariaDB server can tell what local user opens the local socket; do I get it right? What if you do this locally without sudo (and without -u you used in the question)?