title: (Azure) MySQL: MySQL Server Has Gone Away
body: <p>Following the <a href="https://azure.microsoft.com/en-us/documentation/articles/sql-database-connectivity-issues/" rel="nofollow">guide on Azure,</a> <a href="https://azure.microsoft.com/en-us/documentation/articles/sql-database-configure-firewall-settings/" rel="nofollow">configuring the firewall settings</a>, I am still unable to access my MySQL database.  I get the following from ALL servers, even if the IP address is whitelisted:</p>
  
  <blockquote>
    <p>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</p>
    
    <p>Warning: PDO::__construct(): MySQL server has gone away in
    C:\Users\admin\app\dbtest.php on line 3</p>
    
    <p>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
                                <a href="https://azure.microsoft.com/en-us/documentation/articles/sql-database-configure-firewall-settings/" rel="nofollow">2</a> => admin
                                <a href="https://azure.microsoft.com/en-us/documentation/articles/sql-database-configure-firewall-settings/" rel="nofollow">2</a> => pass
                            )
                    )
            )
        [previous:Exception:private] => 
        [errorInfo] =>  ) 1 Process finished with exit code 0</p>
  </blockquote>
  
  <p>Here is my PHP script to connect:</p>
  
  <pre><code>&lt;?php
  try {
      $conn = new PDO("mysql:dbname=db;host=app.database.windows.net;port=1433", "admin", "pass");
  
      $conn-&gt;setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
  }
  catch (PDOException $e) {
      print("Error connecting to SQL Server.");
      die(print_r($e));
  }
  </code></pre>
  
  <p>What are general connection settings required to connect to an Azure MySQL database without the connection timing out?</p>