The main reason for dividing a web server and a database server are the dedicated resources. Generally, with php, it has a wide variety of configurations that allow the configuration to use a variety of resources. With mysql, your my.cnf file allows you to set several configurations, and depending on your maximum "connections" configuration, you will use a range of RAM. By separating the two, you can configure the database server to have a dedicated amount of RAM, CPU and allow the web server to have its own set of resources. By having them on the same server, increases the chances of a service monopolize resources and starve the other, which can cause collisions or changes, since the servers try to load additional RAM and can not find any. In adverse situations, the server can start killing processes to free resources (sometimes it can be the mysql daemon). If you are running a small wordpress or drupal website, then this is not a big problem, and you should keep it on the same server.
If you are running a large volume site, you may want to split your configuration so that mysql runs on an SSD server, and your web server runs separately, with more space, on an HDD server. Since most of the resources will be stored in RAM, the gain of having your web service in SSD is not much compared to MySQL. And mysql will get an extra boost of reading / writing that SSD offers, while keeping costs lower.
In any case, the OP asked him if he could, and of course he can. My recommendation is to dump your database.
mysqldump [database] > [database].dump
transfer it to the external mysql server, import it
mysql [database] < [database].dump
and then make sure to create the mysql user in the external database, and configure the ip / domain of the web server for the host. You do not want to allow% (nobody) access. If you are familiar with it, block port 3306 on the web server and then on the web server, run a test to verify that you can connect to the external database server
mysql -u[user] -p -h[external database domain/ip] [database]
I recommend doing this, since you can spend a lot of time debugging why things do not work, when it can simply be an invalid user configuration in the external database.
If you are using cPanel, there is an option for external databases, so you can allow access to a specific external domain. If you have problems, open a ticket with your hosting provider, as they can block external access to port 3306 (mysql), which could cause you a lot of time and frustrations.