【问题标题】:Lost connection to MySQL server at 'reading initial communication packet', system error: 0 in connecting to Mysql in cpanel在“读取初始通信数据包”时失去与 MySQL 服务器的连接,系统错误:0 在连接到 cpanel 中的 Mysql
【发布时间】:2013-11-08 09:03:14
【问题描述】:

我正在使用 cPanel 服务器,但出现此错误。

“读取初始通信数据包”时与 MySQL 服务器的连接丢失,系统错误:0

虽然我读了他的问题 Lost connection to MySQL server at 'reading initial communication packet', system error: 0 ,但我仍然没有得到解决方案。当我运行我的 php 代码时,它会返回

"Connection successfulLost connection to MySQL server at 'reading initial communication packet', system error: 0"

代码如下:

$con = mysql_connect('mysite.com:2082', 'me@mysite.com', 'passwordhere', 'dbname');

if (mysqli_connect_errno($con))
  {
   echo "Failed to connect to MySQL: " . mysqli_connect_error();
  }
else
{
    echo "Connection successful";
}
if ($selected = mysql_select_db("dbname",$con) or die(mysql_error())){
    echo "Your database name is dbname";
}


mysqli_close($con);

感谢您的回答。

【问题讨论】:

    标签: php mysql


    【解决方案1】:

    我能够解决它。这是代码:

        $con = mysql_connect('localhost', 'serverusername', 'serverpassword');
    
        if (mysqli_connect_errno($con))
          {
          echo "Failed to connect to MySQL: " . mysqli_connect_error();
          }
    
        $selected = mysql_select_db("db_name",$con) or die(mysql_error());
    

    【讨论】:

      猜你喜欢
      • 2011-08-10
      • 2015-03-17
      • 2022-01-16
      • 2011-10-09
      • 2011-11-23
      • 2015-06-29
      相关资源
      最近更新 更多