Advice on best way to have MMO server with MySQL

Hi,

I have been looking around at other peoples assets about creating a login and database connection but they all seem to have their own ideas on the way to do it.

I will currently be using a photon cloud server and I have a server that is creating the room (separate server project), what I am asking is what is the best/secure way to connect to the database?

Do I run the database on the same machine as the server room creator? or use my hosting plan?
Do I have it that it jumps to the server and then the server side calls the database?

I am just after the best structure to use please?

Thanks

It is never advisable to have a database accessible directly via a public IP or connection as this is a massive security risk.

It is always better to have any connections between a server and a database run on an internal network.

I use AWS servers with one as my MYSQL server and my game servers running on other servers. The game servers have Public IP’s that allow users to connect to the directly but only on limited ports, and then they in-turn use an internal network/IP to connect to the dbase.

I then have a replication system to replicate certain data from the mysql server over to my hosted webserver /mysql server to allow users to see their details via a web login.

Hope that makes sense, thats my preferred method.