Most servers do not allow to connect to the database remotely. You should check this with your hosting service provider or the server administrator.
There should be no problems with connecting to remote MySQL database if all the permissions are set correctly and firewall is configured properly or turned off (not recommended) both on your computer and your web hosting server.
When trying to connect to a remote database server, please make sure that the Host, Port, Username and Password values are entered correctly. If you are not sure about any of these, please contact your hosting service provider or the server administrator.