Need to know more about your setup to diagnose the problem ...
Is the grid and website on the same server?
Is the mysql on the same server as the web server , grid server etc?
Has mysql been configured to allow access from outside the network(it is not by default)?