0

I have a remote database: 83.171.40.98, user and password lets say: ***** and trying to connect using phpmyadmin.

I have edited lines like this in: config.inc.php

    $cfg['Servers'][$i]['user'] = 'user';
    $cfg['Servers'][$i]['password'] = '*****';
    $cfg['Servers'][$i]['host'] = '83.171.40.98';

But I get this error: mysqli_real_connect(): (HY000/2002): A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond.

What can be the issue?

  • Did you check the port on which the database listens for connections? – luksch Apr 27 '19 at 15:27
  • After some tweaking I got this error now: `mysqli_real_connect(): (HY000/2002): A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond.` – Nomad Faces Apr 27 '19 at 15:33
  • Possible duplicate of [mysqli::mysqli(): (HY000/2002): Can't connect to local MySQL server through socket 'MySQL' (2)](https://stackoverflow.com/questions/13769504/mysqlimysqli-hy000-2002-cant-connect-to-local-mysql-server-through-sock) – luksch Apr 27 '19 at 15:36

1 Answers1

0

The maximum execution time for PHP scripts is set to 30 seconds by default, so if a script runs for longer than 30 seconds, PHP stops the script and reports an error.

The file you are looking for is php.ini file. Edit that file, find max_execution_time and increase from the default 30 to higher amount of time, say 180. Like this: before: max_execution_time=30 after: max_execution_time=180 Save the file and restart Xampp.

This may also mean an underlying issue, like blocked port, unreachable host or IP, wrong username or password. You may want to check those with regular php connections....

Try PDO like so:

//connect to database   
      function dbconnect(){
        $servername = "localhost"; $username = "yourusernae"; $password = "yourpassword"; $dbname = "yourdbname";

        try{
        $pdoconn = new PDO("mysql:host=$servername;dbname=$dbname", $username, $password);
        $pdoconn->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
        }catch(PDOException $e){
            die("OOPs something went wrong. Connection Failed.");
        }
            echo 'Connected to MySQL';
        return $pdoconn;
      }

You may also want to disable your firewall and antivirus, then try again with these disable just to rule out any of these being the culprit.

You can also try MySQL Workbench too, it works quite well.

pasignature
  • 577
  • 1
  • 6
  • 13