connection php mysqli (Connection refused)

1

Weird from nothing my php does not connect with my mysql, phpMyAdmin normally works.

I ran a sudo /etc/init.d/mysql status and everything is ok.

My php looks like this:

$ip_bd_mysql_master = '127.0.0.1';
$login_bd_mysql_master = 'root';
$senha_bd_mysql_master = '123456';

// Conexão
$mysqli = mysqli_connect($ip_bd_mysql_master, $login_bd_mysql_master, $senha_bd_mysql_master, 'teste');

The error I have is this:

Warning: mysqli_connect(): (HY000/2002): Connection refused in /var/www/html/bd.php on line 6

Does anyone know what it can be?

The version of my php is PHP 7.2.13-1 + ubuntu18.04.1 + deb.sury.org + 1 (cli) (built: Dec 7 2018 08:07:36) (NTS)

    
asked by anonymous 20.12.2018 / 15:03

1 answer

0

The error was in my mysql.

I changed the /etc/mysql/mysql.conf.d/mysqld.cnf file.

I changed the line bind-address = 127.0.0.1 to bind-address = 0.0.0.0

Then I restarted mysql and it worked.

    
28.12.2018 / 11:04