问题描述
我正在尝试通过专用服务器上的localhost连接到mySQL服务器,但是我不断收到错误消息:
I am trying to connect to my mySQL server through localhost on my dedicated server, but I keep getting the error:
Lost connection to MySQL server at 'reading initial communication packet', system error: 110
代码:
<?php
$link = mysql_connect('localhost', '****', '****');
if (!$link) {
die('Could not connect: ' . mysql_error());
}
我尚未配置防火墙,因此所有端口均应打开.我需要做什么?我已经检查了其他几个类似的问题,但是没有一个解决了我的问题. 我没有远程连接.
I haven't configured a firewall, so all ports should be open. What do I need to do? I have already checked several other similar questions, but none of them solved my problem. I am not connecting remotely.
更新
好的,我发现与服务器的连接有问题(我连接了两次).我现在可以连接到服务器,但是当我运行任何查询时,服务器将返回FALSE.我以前曾经使用过此代码,以前也可以使用,但是现在我更换了服务器,它就无法工作.
Okay I found the issue with the connection to the server (I was connecting twice). I am able to connect now to the server, but when I run any query, the server returns FALSE. I have used this code before and it has worked before, but now that I have changed servers, it is not working.
谢谢
大卫
推荐答案
可能是您使用不同的参数连接到数据库
May be you are connecting to your db with different parameters
这篇关于MySQL连接丢失:系统错误:110的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!