2👍
It is possible. In fact, it is even considered a best practice to separate app and database servers.
This talk gives good examples with illustrations about that.
Let’s say you have your app server with ip 189.23.32.32
. Then, you create a database server (with IP 100.10.10.5) and in your server and mysql config files you say that you want to allow requests from this IP on this particular port.
Then, in your Django settings you say that you want to connect to that database. For postgres, it would look like this:
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.postgresql_psycopg2',
'HOST': '100.10.10.5',
'NAME': 'postgres',
'USER': 'postgres',
'PASSWORD': 'password',
},
}
In order to adapt it to MySQL, just change the ENGINE part and you should be good.
Hope it helps!
Source:stackexchange.com