Welcome to Centmin Mod Community
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:
    12:14 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

    55,811
    12,273
    113
    May 24, 2014
    Brisbane, Australia
    Ratings:
    +18,859
    Local Time:
    7:14 PM
    Nginx 1.27.x
    MariaDB 10.x/11.4+
    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:
    12:14 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

    55,811
    12,273
    113
    May 24, 2014
    Brisbane, Australia
    Ratings:
    +18,859
    Local Time:
    7:14 PM
    Nginx 1.27.x
    MariaDB 10.x/11.4+
    FYI you don't need to restart csf firewall when adding or denying ips :)