Error: mysqli_connect(): (HY000/2002):

Asked

Viewed 521 times

-2

When I try to connect to my database by php gives this error: Warning: mysqli_connect(): (HY000/2002): An attempt to turn it on failed because the connected component n answered correctly ap s a per-time, or the set set failed because the host on n answered it. in C: xampp htdocs index.php on line 15 Connection failed: An attempt to turn it on failed because the component on n correctly answered ap s a per odo of time, or the league the established failed because the host on n answered it.

how can I proceed?

<?php
        $servername = "*****";
        $username = "****";
        $password = "*****";

        $conn = mysqli_connect($servername, $username, $password);

        if (!$conn) {
            die("Connection failed: " . mysqli_connect_error());
        }
        echo "Connected successfully";
    ?>

The database is not on the computer but on my company network

1 answer

0

This error happens because you must not be able to access the server.

The first thing is to take a test of telnet

In the prompt dos

telnet $servername 3306 

If you are using for the $servername the server name and not the IP (hostname) maybe you need to set up the etc/hosts or use the server IP to connect

First take the test of telnet and put the answer on the topic

Browser other questions tagged

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