How to connect my wordpress plugin to a remote database securely?

I’d recommend setting up an API, and also ensuring the sites are HTTPS (have an SSL certificate) to encrypt communication between the servers.

If you don’t have one already, there are free certifiers such as https://letsencrypt.org/