Can't connect to database

Discussion in 'MySQL' started by B2UEntertainment, Jul 4, 2008.

  1. #1
    I'm trying to connect to my mysql database from an external web server. I added the servers IP address as a trusted site so it can access it remotely.

    I realize this is an error with the external server and not the main server the database resides on because I tried it with another external server and it worked.

    Anyways here is the message I get when I try to make a database connection from the external server. The X's are private info.

    Warning: mysql_connect() [function.mysql-connect]: Can't connect to MySQL server on 'XXXX' (4) in /home/XXXX/public_html/newserverdb.php on line 4
    Could not connect: Can't connect to MySQL server on 'XXXXX' (4)

    Any help would be appreciated.
     
    B2UEntertainment, Jul 4, 2008 IP
  2. mwasif

    mwasif Active Member

    Messages:
    816
    Likes Received:
    23
    Best Answers:
    1
    Trophy Points:
    70
    #2
    Where did you add this?

    To access MySQL database you must allow your MySQL user to access database remotely. Set the MySQL user access permissions remotely by adding a remote IP instead of localhost.
     
    mwasif, Jul 5, 2008 IP
  3. gigapros

    gigapros Active Member

    Messages:
    71
    Likes Received:
    9
    Best Answers:
    0
    Trophy Points:
    65
    #3
    Most hosting provider blocks port# 3306 due to security reasons. so, even if you add server IP address as a trusted site, you won't be able to can access it remotely. Check with your hosting provider first.
     
    gigapros, Jul 5, 2008 IP
  4. mwasif

    mwasif Active Member

    Messages:
    816
    Likes Received:
    23
    Best Answers:
    1
    Trophy Points:
    70
    #4
    gigapros is right, some shared hosting providers do not allow remote access for MySQL.
     
    mwasif, Jul 5, 2008 IP
  5. zerofill

    zerofill Member

    Messages:
    34
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    45
    #5
    You tried it with another external server on the same database?
     
    zerofill, Jul 7, 2008 IP
  6. B2UEntertainment

    B2UEntertainment Peon

    Messages:
    102
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    0
    #6
    I have 3 servers.

    One is a VPS and the other two are shared. I'm trying to access one of the shared host with the VPS, but it wont connect. The two shared host can connect with each other, but the VPS cannot connect to either. Now the two shared host can connect to the VPS no problem, but the problem is vice versa. The script runs from one of the shared host and the VPS needs to to connect to this script but I keep getting this error.

    I don't think it's a problem with the shared host because they can connect with each other, and they are from two different providers(Bluehost, Hostmonster). So it's probably the VPS.
     
    B2UEntertainment, Jul 11, 2008 IP
  7. jimpossible2k

    jimpossible2k Active Member

    Messages:
    36
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    51
    #7
    You might have the connection information specified incorrectly. I remember running into these connectivity issues myself and I was using HostMonster. I forget the "trick" that I used to get it working. I can give you a sample of what my connection information looks like though:

    Host Address: hostXXX.hostmonster.com [where XXX is your host box number]
    UserName: mysoft_root [where mysoft is my HostMonster account name, root is my username]
    Password: ******* [whatever you set it to in cpanel]
    Port: 3306
    Database Name: mysoft_mspmain [where mysoft is my HostMonster account name, mspmain is database name]

    I also had to whitelist the IP address of the server that is connecting, which can be done through the cPanel.

    P.S: HostMonster and BlueHost are run by the same parent company, so this information should also be helpful even if
    the database is hosted on BlueHost.
     
    jimpossible2k, Jul 11, 2008 IP
  8. B2UEntertainment

    B2UEntertainment Peon

    Messages:
    102
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    0
    #8
    Thanks jimpossible2k

    "whitelist" was the key. I should have done this a while ago, but I entered their live chat and asked for help since I knew I would have to contact them to add the ip(other than what I did in cpanel). And it worked. They added it to the whitelist on their end and it worked. And I didn't know Hostmonster and Bluehost were owned by the same company, it's probably why their servers can connect to each other, but outside ones have to be added to the whitelist through support.
     
    B2UEntertainment, Jul 12, 2008 IP
  9. justinlorder

    justinlorder Peon

    Messages:
    4,160
    Likes Received:
    61
    Best Answers:
    0
    Trophy Points:
    0
    #9
    check the setting , ip dbname , username password. then google the erro code to view which is the most possible reason to cause the connection failure.
     
    justinlorder, Jul 12, 2008 IP
  10. Joomla_Services

    Joomla_Services Banned

    Messages:
    35
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #10
    You wont be able to connect to an external server at all..
    It wont work out..
     
    Joomla_Services, Jul 12, 2008 IP