(Azure)MySQL:MySQL服务器已经消失

时间:2016-09-14 05:35:23

标签: php mysql azure pdo azure-sql-database

guide on Azure, configuring the firewall settings之后,我仍然无法访问我的MySQL数据库。我从所有服务器获得以下内容,即使IP地址列入白名单:

  

PHP警告:PDO :: __ construct():MySQL服务器已经消失了   第3行PHP上的C:\ Users \ admin \ app \ dbtest.php   警告:PDO :: __ construct():读取问候数据包时出错。   在线C:\ Users \ admin \ app \ dbtest.php中的PID = 11692   3

     

警告:PDO :: __ construct():MySQL服务器已经消失了   第3行的C:\ Users \ admin \ app \ dbtest.php

     

警告:PDO :: __ construct():读取问候数据包时出错。   在线C:\ Users \ admin \ app \ dbtest.php中的PID = 11692   3连接到SQL Server.PDOException对象时出错(       [message:protected] => SQLSTATE [HY000] [2006] MySQL服务器已经消失       [string:Exception:private] =>       [code:protected] => 2006年       [file:protected] => C:\用户\ ADMIN \程序\ dbtest.php       [line:protected] => 3       [trace:Exception:private] =>排列           (               [0] =>排列                   (                       [file] => C:\用户\ ADMIN \程序\ dbtest.php                       [line] => 3                       [function] => __构造                       [class] => PDO                       [type] => - >                       [args] =>排列                           (                               [0] => MySQL的:DBNAME = mydb的宿主= app.database.windows.net;端口= 1433                               2 =>管理                               2 =>通过                           )                   )           )       [上一个:例外:私人] =>       [errorInfo] => )1处理完成,退出代码为0

这是我要连接的PHP脚本:

<?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));
}

在没有连接超时的情况下连接到Azure MySQL数据库所需的常规连接设置是什么?

1 个答案:

答案 0 :(得分:1)

格式为% Created by: DarkRiot43 % Student #: % Date: Sept 12, 2016 % Course: Numerical Analysis, MTH 510 function [ ] = MacLaurin( func , valueOfx, sigfigs ) %MACLAURIN Summary of this function goes here % Detailed explanation goes here % inputs: func: a function % sigfigs: the number of significant figures you would like % to have the answer evaluated to. clc; syms f(x) x ; f(x) = func; presentApprox = 0; previousApprox = 0; n = 0; % Find the criterion for stopping the iteration as an double not a percent. Es = (0.5*10^(2-round(sigfigs)))/100; Ea =Es+1; % Ensures Ea is larger than Es to begin while Ea >= Es %differentiate the n'th derivative of the equation f(x) w.r.t. x beenDiff = diff(f(x),n); presentApprox = previousApprox + (vpa(subs(beenDiff,x,0))* (((valueOfx)^n)/factorial(n))); %MacLaurin series structure used to evaluate. n = n+1; %Counter incrementation % Call to function approxError to determine approximate relative error. Ea = approxError(presentApprox,previousApprox); previousApprox = presentApprox; f(x) = beenDiff; % can be used to ensure proper iterating counting of the program disp(n); disp(f(x)); %shows the n'th derivative function %check to see if in the approxError function there would have been a %by zero error. if so I edit the value (999 was all i could think of? % was thinking of using something else but didn't know what to use if Ea == 999 break; end end else fprintf('\nStopping criterion used:\t'); disp(Es*100) fprintf('The estimate generated using MacLaurin Series of '); disp(func); fprintf('using the value x = %.3f is: \n\n',valueOfx); fprintf('%7f',presentApprox); fprintf('\nThis was done using %d iterations', n); if Ea == 0 fprintf('\nCould not reach the requested stopping criterion.'); end end function [Ea] = approxError(presentApprox,previousApprox) %Approximate relative error Function % inputs: % presentApprox: type double % previousApprox: type double % returns: % Ea: type double % % Uses two values to determine the approximate relative error w.r.t % eachother if presentApprox ~= 0 Ea = (presentApprox - previousApprox)/(presentApprox); elseif presentApprox == 0 disp('Cannot determine the value with more precision as it would involve dividing by zero!'); Ea = 999; end end 的数据库端点是Azure SQL的端点,它提供SQL Server服务。不是MySQL。请尝试在https://www.microsoft.com/en-us/download/details.aspx?id=20098安装Windows的SQL Server驱动程序。然后尝试使用app.database.windows.net;port=1433连接到Azure SQL。

如果您想在Azure上使用MySQL BaaS,可以参考https://azure.microsoft.com/en-us/documentation/articles/store-php-create-mysql-database/了解详细步骤。

如有任何疑问,请随时告诉我。