MySQL error 2002 connection refused

1

I hosted a site on 007gb.com and I am trying to access my remote database but I get the message

"Mensagem do erro: SQLSTATE[HY000] [2002] Connection refused
Code: 2002
Fatal error: Call to a member function prepare() on string in /srv/disk13/2292110/www/pirataswe0.medianewsonline.com/test.php on line 14"

What can it be? I created a script in php to facilitate:

<?php

function connectdb() {
    try {
        $return = new PDO("mysql:host=179.213.XX.XX;port=3306,dbname=pwdb;charset=utf8", 'root', '***********',[PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION]);
    } catch (PDOException $exc) {
      echo  $return = 'Mensagem do erro: ' . $exc->getMessage().
         '<br>Code: ' . $exc->getCode();
    }
    return $return;
}

$db = connectdb();
$select = $db->prepare("SELECT title FROM posts");
$select->execute();
echo $select->rowCount().'</br>';
while ($data = $select->fetch(PDO::FETCH_ASSOC)) {
    echo $data['title'].'</br>';
}

The port is the same standard, and it is open at the gateway that points to the local ip and port.

    
asked by anonymous 06.02.2017 / 01:21

1 answer

-2

To solve this problem, simply follow the steps below. First of all let's install the database in MySQL:

# mysql_install_db

Next you need to generate the sock:

# chown -R mysql.mysql /var/lib/mysql

Now let's start MySQL server:

# safe_mysqld &

Beauty, your MySQL is already running!

Open another terminal window and type:

# mysql

I hope I have helped!

    
06.02.2017 / 03:01