php mysqli connection (Connection refused)

Asked

Viewed 2,114 times

1

Strange of nothing my php does not connect with my mysql, phpMyAdmin normally.

Rodei a sudo /etc/init.d/mysql status and it’s all okay.

My php is 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 mistake 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 )

  • Try to put the host emptiness : $ip_bd_mysql_master = '';

  • with it empty the error changes: Warning: mysqli_connect(): (HY000/1045): Access denied for user 'root'@'localhost' (using password: YES) in

  • Are you sure the access data is correct?

  • Yes, via terminal I connect well, using mysql -h 127.0.0.1 -u root -p the only change I made yesterday on my pc was to set up a second site on port 81 of the acpache, but I don’t think that has anything to do. And as I said phpMyAdmin connects well.

  • @Andersoncarloswoss vlw by help, the error was in my mysql. I changed the file /etc/mysql/mysql.conf.d/mysqld.cnf. I changed the line bind-address = 127.0.0.1 for bind-address = 0.0.0.0`

1 answer

0


The error was in my mysql.

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

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

Then I restarted mysql and it worked.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.