"But the username and password are OK."
MySQL does not only authenticate by username and password, it also uses the hostname.
When you logon locally, you have access for user 'bla@localhost'
To connect from remote, you must have access for 'user@hostyouareconnectingfrom'
If this is your own server, and you have administrative rights on the mysql server, you can use the GRANT statement in SQL to add the rights, something like
GRANT all ON database.* TO user@remotehost IDENTIFIED BY 'password';
I urge you to read the MySQL documentation about the GRANT statement and about how the MySQL 'privileges system' works.
Doing this 'badly' can create serious security holes which hackers will find.