0

I am following this tutorial to try and connect to my remote database on Microsoft Azure.

I am trying to follow this tutorial here.

The code is reproduces below for ease of access:

$sUsername = '*****';
$sPassword = '*****';
$sHost = 'eu-cdbr-azure-west-d.cloudapp.net';
$sDb = 'database';


    try {
          $oConn = new PDO('mysql:host='.$sHost.';dbname='.$sDb, $sUsername, $sPassword);
          $oConn->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);

          echo 'Sucess!';


        } catch(PDOException $e) {
           echo 'ERROR: ' . $e->getMessage();
    }

I'm getting this error:

PHP Fatal error:  Uncaught exception 'PDOException' with message 'SQLSTATE[HY000] [2003] Can't connect to MySQL server on 'eu-cdbr-azure-west-d.cloudapp.net' (110)' in db-connector.php:46
Stack trace:
#0 db-connector.php(46): PDO->__construct('mysql:host=eu-c...', 'bfb1d94b7476ad', 'bf430620')
#1 {main}
  thrown in /home/maltawed/public_html/library/db-connector.php on line 46`
user6043723
  • 177
  • 2
  • 14
  • duplicate of yours ? http://stackoverflow.com/q/38343168 ... nevermind, it seems you connected last nite. Maybe you are just new to all of this. Probably little we can do. – Drew Jul 13 '16 at 13:38
  • Yeah it is. I'm still learning on my own so its all trial and error :-) – user6043723 Jul 13 '16 at 20:56

1 Answers1

1

Dose your test script on Azure Web Apps environment or you tested your code on local?

If you are testing on local, you can check:

You may want to check with your local network administrator and/or ISP to ensure that you are allowed to access remote resources that run on TCP 3306. It is possible that this port has been blocked from your local network and/or machine. To be clear, we performed a connection test on this database and found that it is operating normally, so the next diagnostic step is to check your local connectivity to remote MySQL databases.

According the issue error trying to connect to cleardb.

Otherwise, as MySQL server on Azure is provided by ClearDB, you can contact to the ClearDB support team at https://www.cleardb.com/developers/help/support for detailed analyze about your clearDB database.

Community
  • 1
  • 1
Gary Liu
  • 13,758
  • 1
  • 17
  • 32