0

I can't connect to my MySQL database which is held by a hosting provider.

I've set up accounts correctly in cPanel so I can connect to database when I run my php code from phpadmin server.

But now I want to access it from a database tool on Mac rather than phpmyadmin. I've added my IP (both IP and DNS name..) to "Remote Database Access Hosts" in cPanel. I've tried to connect both from PHP and directly. I always get:

MySQL Said: Can't connect to MySQL server on 'xxx.xxx.xxx.xxx' (4)

Use the following configuration settings for connecting to your database:

I have tried this:

  1. Host name = (use the server IP address)
  2. Database name =(cpanelUsername_databaseName)
  3. Database username = (cpanelUsername_databaseUsername)
  4. Database password = (the password you entered for that database user)
  5. MySQL Connection Port = 3306
4
  • 1
    Could be that the hosting provider does not allow you accessing your database from an other ip adress Commented Jan 26, 2014 at 13:35
  • Your adding the IP of your computer right? Not the IP of your server. Commented Jan 26, 2014 at 13:36
  • not sure if this was the case, but if it was why would they provide a way to whitelist an ip ? Commented Jan 26, 2014 at 13:36
  • I am adding the ip i foind on whatmyip.com Commented Jan 26, 2014 at 13:36

1 Answer 1

2

If you have access to phpMyAdmin you might be able to edit the user account created by cpanel. In the "Users" tab, go to "Edit privileges" on the user you want to use from remote. Then there should be a popup where you can scroll down and find a section called "Login Information".

The value set for "Host" is "localhost" by default, set this to "%" (without quotes) for that user to be used from every remote IP address.

Sign up to request clarification or add additional context in comments.

1 Comment

This could leave CodeMonkey without a way to access the database -- since 'localhost' is special to MySQL and % doesn't include localhost, it's possible that could remove the only means by which to access the database. Better to create a new user, but as noted elsewhere that's probably not going to be allowed by the hosting provider due to security concerns.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.