MySQL服务器已经不复存在:Microsoft Azure, [英] MySQL server has gone away: Microsoft Azure,

查看:37
本文介绍了MySQL服务器已经不复存在:Microsoft Azure,的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

好的,我已经使用Web应用程序创建了一个Azure虚拟机.我还创建了一个azure服务器,以及与该服务器一起使用的数据库.所有人都已连接并且正在工作.我什至在数据库上运行查询并链接了github存储库.

OK I have created an azure virtual machine with a web app. I also created an azure server, and a database to go with the server. All are connected and working. I have even ran queries on the database and linked a github repository.

首先,我已经在本地xampp服务器上使用phpmyadmin配置了所有内容.在xampp服务器上,网站的所有内容都可以正常工作,但是,当我更改服务器主机,用户,密码和数据库的值时,尝试连接数据库时收到sql错误.

First I have configured everything with phpmyadmin on a local xampp server. On the xampp server everything with the website is working fine, however when I change the value of the server host, user, pass, and database I receive an sql error when attempting to connect to the database.

下面是我用来连接数据库的代码.

Bellow is the code I use to connect to the database.

每次运行此代码时,都会收到错误消息:无法连接到MySQL:

Every time I run this code I receive the error Failed to connect to MySQL:

MySQL服务器已消失

MySQL server has gone away

$db = mysqli_init();
mysqli_real_connect($db, $sname, $dbUser, $dbpass, $dbName, 1433);
if (mysqli_connect_errno($db)) {
die('Failed to connect to MySQL: '.mysqli_connect_error());
}

推荐答案

根据您的描述和评论,我有充分的理由相信您所说的Azure上的MySQL服务器实际上是一个Azure SQL数据库实例(MS SQL Server在Azure云上.

According to your description and comments, I have good reason to believe that the MySQL server on Azure as you said is actually an Azure SQL database instance (MS SQL Server on Azure cloud).

如果您在Azure门户上看到连接字符串,如下图所示,则它实际上是Azure SQL数据库,而不是用于MySQL服务器的Azure数据库.

If you see your connection string on Azure portal as the figure below, it's actually Azure SQL database, not Azure Database for MySQL server.

因此,正如您所说,您会看到Azure使用如上所述的 sqlsrv_connect 函数提供了一个连接字符串.

So as you said, you see Azure gives a connection string using sqlsrv_connect function as above.

Azure数据库for MySQL的实际连接字符串应如下所示.

The real connection string for Azure Database for MySQL should be as below.

这篇关于MySQL服务器已经不复存在:Microsoft Azure,的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆