Step 1: Login to your cPanel account.
Step 2: Click the Remote MySQL button in the Databases section.
Step 3: Enter the remote IP address in the Add Access Host section.
Step 4: Click the Add Host button.
Step 5: You will then see a message stating the host IP address was added to the access list.
Step 6: You should use the remote IP address as a hostname instead of localhost in your database configuration file.