Following the guide on Azure, configuring the firewall settings, I am still unable to access my MySQL database. I get the following from ALL servers, even if the IP address is whitelisted:
PHP Warning: PDO::__construct(): MySQL server has gone away in C:\Users\admin\app\dbtest.php on line 3 PHP Warning: PDO::__construct(): Error while reading greeting packet. PID=11692 in C:\Users\admin\app\dbtest.php on line 3
Warning: PDO::__construct(): MySQL server has gone away in C:\Users\admin\app\dbtest.php on line 3
Warning: PDO::__construct(): Error while reading greeting packet. PID=11692 in C:\Users\admin\app\dbtest.php on line 3 Error connecting to SQL Server.PDOException Object ( [message:protected] => SQLSTATE[HY000] [2006] MySQL server has gone away [string:Exception:private] => [code:protected] => 2006 [file:protected] => C:\Users\admin\app\dbtest.php [line:protected] => 3 [trace:Exception:private] => Array ( [0] => Array ( [file] => C:\Users\admin\app\dbtest.php [line] => 3 [function] => __construct [class] => PDO [type] => -> [args] => Array ( [0] => mysql:dbname=mydb;host=app.database.windows.net;port=1433 2 => admin 2 => pass ) ) ) [previous:Exception:private] => [errorInfo] => ) 1 Process finished with exit code 0
Here is my PHP script to connect:
<?php
try {
$conn = new PDO("mysql:dbname=db;host=app.database.windows.net;port=1433", "admin", "pass");
$conn->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
}
catch (PDOException $e) {
print("Error connecting to SQL Server.");
die(print_r($e));
}
What are general connection settings required to connect to an Azure MySQL database without the connection timing out?