Learn about Centmin Mod LEMP Stack today
Become a Member

Need help ASAP, error HY000/2002 while connect to remote via Mysqli or PDO

Discussion in 'Introductions' started by kabantejay, Feb 19, 2016.

  1. kabantejay

    kabantejay New Member

    11
    0
    1
    Feb 19, 2016
    Ratings:
    +0
    Local Time:
    9:32 PM
    MariaDB 10
    hi! please, eva2008, help me, i'm stuck
    im from ukraine sorry for bad english.
    CentOS 6.7 64bit, installed stable last centminmod
    mariadb 10

    everything works fine except remote connection to mysql DB via mysqli or PDO:
    Code:
    $mysqli  = new mysqli($host, $user, $pass, $db);
    if ($mysqli->connect_error) {
        die('Error (' . $mysqli->connect_errno . ') '
                . $mysqli->connect_error);
    }
    if (mysqli_connect_error()) {
        die('Error (' . mysqli_connect_errno() . ') '
                . mysqli_connect_error());
    }
    echo 'SUccess... ' . $mysqli->host_info . "\n";
    $mysqli->close();
    this code works fine with localhost, but i need to connect to remote DB to use SMS sending service.
    the code above and the whole module works well on other shared hosting, but on VPS with centminmod i'm in trouble((

    i also tried to add port 3306 and socket directli to new mysqli($host, $user, $pass, $db, $port, $socket);
    but this not helped.
     
  2. eva2000

    eva2000 Administrator Staff Member

    30,156
    6,785
    113
    May 24, 2014
    Brisbane, Australia
    Ratings:
    +10,136
    Local Time:
    4:32 AM
    Nginx 1.13.x
    MariaDB 5.5
    Centmin Mod LEMP stack installs CSF Firewall out of the box, so to be able to remotely connect to external servers, you need to whitelist and allow the remote IP address see the info below:
    welcome @kabantejay to Centmin Mod Community

    Threads you might want to participate in ;)
    Threads to read, pages to bookmark and threads to watch/subscribe to get to know Centmin Mod would include:
    Premium Membership
     
  3. kabantejay

    kabantejay New Member

    11
    0
    1
    Feb 19, 2016
    Ratings:
    +0
    Local Time:
    9:32 PM
    MariaDB 10
    great! thanks a lot!!

    everything i need was:
    1. csf -a XX.XXX.XXX.XXX
    (where xxx.xxx... - is IP of remote host what i was trying to connect to)
    2. csf -r
    (is to restart the firewall)
     
  4. eva2000

    eva2000 Administrator Staff Member

    30,156
    6,785
    113
    May 24, 2014
    Brisbane, Australia
    Ratings:
    +10,136
    Local Time:
    4:32 AM
    Nginx 1.13.x
    MariaDB 5.5
    FYI you don't need to restart csf firewall when adding or denying ips :)