The Community Forums

Interact with an entire community of cPanel & WHM users!
  1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

[Solved] Remote MySQL connection not working

Discussion in 'Database Discussions' started by n000b, Feb 1, 2011.

  1. n000b

    n000b Well-Known Member

    Apr 7, 2005
    Likes Received:
    Trophy Points:
    Edit: I'm an idiot, the error is showing me the server the connection is coming from, not going to. I checked the remote server's cPanel remote access page, and my customer had added their domain in. It appears as though cPanel requires the entry in the remote access page to match the hostname that MySQL sends for the connection - once I added my servers hostname (even though it resolves to the same IP as the customers domain), it worked fine :)


    One of my customers contacted me with an interesting problem - they have a website which is hosted on my server, and they want to host a PHP script that connects to a MySQL database on another server (not owned by me).

    They are testing with this script:

    $con = mysql_connect("<other-server>","<username>","<password>");
    if (!$con)
      die('Database Error: ' . mysql_error());
    When tested, the script is giving this error:

    Warning: mysql_connect() [function.mysql-connect]: Access denied for user '<username>'@'<my-server>' (using password: YES) in /home/username/public_html/ConnectDB2.php on line 5
    Database Error: Access denied for user '<username>'@'<my-server>' (using password: YES)
    Note that the error is saying that it is trying to connect to *my* server, not the remote server.

    I'm not sure if this is a PHP problem or a MySQL problem so I have put this here - does anyone know why PHP or MySQL is trying to connect to my server, when we are specifying the remote server?

    I believe that my customer has added my server to the remote server's cPanel "Remote Database Access Hosts" feature, but it looks like the problem is occuring before the connection even reaches the remote server.

    Any ideas?
    #1 n000b, Feb 1, 2011
    Last edited: Feb 1, 2011
  2. coderiser

    coderiser Member

    Jan 31, 2011
    Likes Received:
    Trophy Points:
    make sure you have filled in your variables fill them in with your actual username, server, password, and database to complete your connection

Share This Page