Connecting MySQL database to server

Hello everyone,
I have deployed a shiny app on server. This app is connected with a MySQL database. So when I was working locally, I have connected the db like below -

mydb <- dbConnect(MySQL(),
                  user = 'root',
                  password = '',
                  dbname = 'test',
                  port = 3306)

But I do not know how to connect the database when the app is live on the server.

Can anyone help me with this issue? How can I connect MySQL database with live app?
Thanks in advance.

You need to expose the MySQL server to the public internet through a public IP and open port and specific those in the connection parameters.

If you are running a home server you can follow along with this blog post for an example of how to expose a service to the public internet.

If the server is managed by an IT department then you should ask them for support since most likely you would not have the permissions required to configure yourself.