在bluehost上设置mysql的远程访问

Trying to set up and host a db on Bluehost but having issues when testing it locally. Setting connection string as $link = mysqli_connect("localhost", "username", "password", "dbname") ` but I keep getting "No connection could be made because the target machine actively refused it".

I should note that I'm setting the database as a remote connection.

It seems permission is granted, try to grant the permission first. Here "%" mean Db can accept the connection from any IP, if you want to make DB can accept the connection from specific hostname for IP then instead of "%" use the hostname or IP.

GRANT ALL PRIVILEGES ON dbname.* TO 'username'@'%';