Connecting to a Remote MySQL database on my VPS

Discussion in 'Linux VPS/Dedicated - General' started by pcutler, May 20, 2009.

  1. pcutler

    pcutler New Member

    Hi all, I need some help trying to connect to a mysql db on my VPS.

    I'm running a Counter-Strike server here at my house, and I want to stream statistics from that server to my db on my vps.

    The perl script that streams the stats, has a config file:

    dbtype = mysql
    dbhost = mydomain
    dbport =
    dbname = mydb
    dbuser = mydbuser
    dbpass = mydbpw
    dbtblprefix = ps_

    I've tried the dbhost field as my domain name, and ip address, and for dbport I've put in 3306.

    I get the error:

    Error connecting to database using dsn "DBI:mysql:database=mydb;host=mydomain.com;port=3306":
    Host 'c-75-72-118-230.hsd1.mn.comcast.net' is not allowed to connect to this MySQL server

    It's as if if my home IP address isn't allowed to connect remotely. And I did check to see that the DBI:mysql perl module is installed.

    Do mysql databases on the Linux VPS plan allow for remote connections? Searching through the forums I thought it looked like it, and that's where I saw to use port 3306.

    Running the same perl script on my VPS itself, I get a different error:

    Access denied for user 'mydbuser'@'localhost' (using password: NO) - I'm not sure where to fix that one yet, it should be using my password.

    Any suggestions?

    Thanks.
     
  2. mylinear

    mylinear Member

    I do not have an exact answer. But in cPanel, there is an option "Remote MySQL" where you can add remote hosts that can access the MySQL database. If you got cPanel, you can check on that.

    Hopefully someone else can give you a proper solution, or you can submit a ticket and see if support can help on this.
     
  3. Devon

    Devon New Member

    mylinear was on the right path with the answer he provided above - what's happening is that you're being blocked out by a built in security measure to prevent hackers or unauthorized access to your databases. You'll have to add you're IP (or the IP of the server trying to connect to your VPS) to the list of hosts allowed to access MySQL on your VPS. You can do this from within' cPanel or WHM.

    Within cPanel:
    - Click on "Remote MySQL" and then add the IP address.

    Within' WHM:
    - Click "Additional MySQL Access Hosts"
    - Add the IP Address in the text area
    - Read the IMPORTANT note at the bottom of that page
    - Save your changes

    Hope this helps,
    - Devon
     
  4. pcutler

    pcutler New Member

    Thanks - can't believe I missed the Remote MySQL option in Cpanel.

    Still not working though, I think it has something to do with not using the password. I'm not sure why the DBI::mysql perl module isn't using the password.

    Trying to run the perl script remotely or on my VPS, I get:

    (Remotely:)

    Access denied for user 'user'@'Access denied for user 'mydbuser'@'myip.hsd1.mn.comcast.net' (using password: NO)
    (using password: NO)

    (In the Remote setup, I added *.comcast.net, *.hsd1.mn.comcast.net and the IP address)

    (On the VPS server:)

    Access denied for user 'mydbuser'@'localhost' (using password: NO)
     
  5. pcutler

    pcutler New Member

    I got it working - it was a password problem.

    Thanks everyone!
     
  6. Devon

    Devon New Member

    I'd be careful opening your MySQL database to allow connections from domains such as *.comcast.net; Comcast is one of the largest ISP's within the US and therefore means you're creating a pretty big security risk by doing so. I'd only allow specific IP Addresses if I were you.

    - Devon
     
  7. pcutler

    pcutler New Member

    Agreed - and changed it to my IP.

    Thanks!

    Paul
     

Share This Page