PHP & SQL - A failed connection attempt - XAMPP

Asked

Viewed 1,080 times

1

Hey, guys, here’s my problem. I own my machine with a Mysql localhost, there is a website that I created, however, when I try to connect the DB of the site with another machine that is not connected to my WI-FI network or the error happens:

Warning: mysqli_connect(): (HY000/2002): An attempt to connect the failed because the connected component n answered correctly ap s a time per or the established connection failed because the host connected did not reply.

This error occurs only on external computers, even though everything works normal on my PC and others that are connected to my WI-FI network.

PHP connection of the site:

define('HOST', '192.168.1.244:3306');
define('USUARIO', 'monty');
define('SENHA', '[senha]');
define('DB', 'login');

$conexao = mysqli_connect(HOST, USUARIO, SENHA, DB) or die ('Não foi possivel conectar!');
mysqli_select_db($conexao, 'login') or die (mysql_error());

A few steps I’ve already taken:

=> Sql accounts have permissions to connect.

=> I already added the host account "%" for any ip.

=> Mysql’s my.ini bind address is IP 0.0.0.0

=> The IP I use in php connection is my ipv4.

=> I already allowed mysql and apache in the firewall, although it is turned off.

=> Apache and Mysql services are connected.

=> The login user of the php connection has global permissions.

=> I’ve already added the "Require all granted" lines to the httpd.xampp.conf file

Print of localhost accounts:

inserir a descrição da imagem aqui

NOTE: All PHP code is being used in PHP Desktop and then converted into an executable by Inno Setup.

Anyway, thanks for your patience!

  • bind 127.0.0.1 would not be correct?

    1. Is your Mysql service online and active ? 2. Do you have a firewall blocking port 3306 ? 3. Have you defined the user accounts and the user you are using to connect has permissions for this ? 4. The server you are trying to connect to is in the list of enabled servers in Mysql ?
  • Also check, what really must be the problem, the ambiguity that the system listens to "localhost", if any, comment on one of them and test again.

  • already released in the firewall access to this port ?

  • @Eliseub. I’m not sure but the bind 127.0.0.1, is only for local access and does not allow remote access from other machines

  • @Eliseub. 1. Yes 2. No 3. I just added permissions so they can connect 4. I haven’t checked this yet

  • @Eliseub. Sorry but how can I do this? I’m new with Mysql

  • @Bulfaitelo Yes, even though the firewall is completely disabled

  • 2

    Rotate this command telnet ip_do_servidor 3306 and send me the result print.

  • Do the test as suggested by Bulfaitelo and post the result

  • @Bulfaitelo telnet 192.168.1.244 3306: Y

 5.5.5-10.1.37-MariaDB*q}?bNB?áWwqQ!OJd8-u(mysql_native_password

Conexão ao host perdida.

  • @Nithogg this test was done on a second machine on the same network ? or on the same server machine ?

  • @Bulfaitelo This was on the same server

  • @Nithogg now does the same test on a machine on the same network.

  • @Bulfaitelo Y
5.5.5-10.1.37-MariaDB);.t!Dp?á~_BheEeM2Q!Mmysql_native_password

Conexão ao host perdida.

  • 1

    Before you continue the test, explain better where you are and this machine, it is outside your network ? or is on the same network (same ip range) ?

  • @Bulfaitelo The second test machine is a notebook that is connected on the same network and same host PC location. The IP of the second machine is practically equal to that of the main machine.

  • 1
Show 13 more comments
No answers

Browser other questions tagged

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