与数据库的连接在读取通信数据包时出错

问题描述 投票:1回答:1

我已经通过备份工具将数据库从cPanel迁移到cPanel,但是问题是,无论何时我尝试使用此TEST php代码连接到该数据库,例如]

<?php
# Fill our vars and run on cli
# $ php -f db-connect-test.php
$dbname = 'imadoulh_test';
$dbuser = 'xxxxx';
$dbpass = 'xxxxx';
$dbhost = 'localhost';
$connect = mysql_connect($dbhost, $dbuser, $dbpass) or die("Unable to Connect to '$dbhost'");
mysql_select_db($dbname) or die("Could not open the db '$dbname'");
$test_query = "SHOW TABLES FROM $dbname";
$result = mysql_query($test_query);
$tblCnt = 0;
while($tbl = mysql_fetch_array($result)) {
  $tblCnt++;
  #echo $tbl[0]."<br />\n";
}
if (!$tblCnt) {
  echo "There are no tables<br />\n";
} else {
  echo "There are $tblCnt tables<br />\n";
}

响应为此页面无效

,并带有HTTP ERROR 500并且MySQL日志显示读取通信数据包时出现错误

很遗憾,我确实尝试了多种方法来修复它。这是我尝试过的:1.优化和修复表2.向/etc/my.conf文件中添加一些代码,例如

     max_allowed_packet=2684354569944
     open_files_limit=10000
     default-storage-engine=MyISAM
     innodb_file_per_table=1
     default_authentication_plugin=mysql_native_password

处理本文:https://dba.stackexchange.com/questions/19135/mysql-error-reading-communication-packets

我已经通过备份工具将数据库从cPanel迁移到了cPanel,但是问题是,每当我尝试使用该TEST php代码连接到该数据库时,就是这样

php mysql database cpanel centos7
1个回答
0
投票

http的错误500表示您的网络程序-您的php程序-尝试发送该页面失败。但是500绝对不能告诉我们为什么

© www.soinside.com 2019 - 2024. All rights reserved.