php mysql.proc 的列数错误。预期 20,找到 16。表可能已损坏
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/16177465/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Column count of mysql.proc is wrong. Expected 20, found 16. The table is probably corrupted
提问by user2086258
I am using 000webhost.com and I am using phpMyAdmin there. I am getting this error from MySQL when I run my PHP script as the title says:
我正在使用 000webhost.com,我在那里使用 phpMyAdmin。当我运行 PHP 脚本时,我从 MySQL 收到此错误,如标题所示:
Column count of mysql.proc is wrong. Expected 20, found 16.
The table is probably corrupted.
mysql.proc 的列数错误。预期 20,发现 16。
该表可能已损坏。
Is there any solution for this?
有什么解决办法吗?
<?php
$username="usrname";
$password="passwd";
$database="a1xxxxx_mydb";
$host="mysqlxx.000webhost.com";
mysql_connect($host,$username,$password);
@mysql_select_db($database) or die( "Unable to select database");
if (isset($_GET["userLatitude"]) && isset($_GET["userLongitude"])) {
$userLatitude=$_GET['userLatitude'];
$userLongitude=$_GET['userLongitude'];
$result = mysql_query("SELECT locationName, ( 6371 * acos( cos( radians(floatval( $userLatitude) )) * cos( radians( locationLatitude ) ) * cos( radians( locationLongitude ) - radians( floatval($userLatitude)) ) + sin( radians(floatval($userLongitude)) ) * sin( radians( locationLatitude) ) ) ) AS distance
FROM Location HAVING distance < 2 ORDER BY distance LIMIT 0 ,20") or die(mysql_error());
echo $result;
// check for empty result
if (mysql_num_rows($result) > 0) {
// looping through all results
// products node
$response["Location"] = array();
while ($row = mysql_fetch_array($result)) {
// temp user array
$product = array();
$product["locationName"] = $row["locationName"];
$product["locationInfo"] = $row["locationInfo"];
$product["locationLatitude"] = $row["locationLatitude"];
$product["locationLongitude"] = $row["locationLongitude"];
$product["locationPic"] = $row["locationPic"];
$product["city"] = $row["city"];
// push single product into final response array
array_push($response["Location"], $product);
}
// success
$response["success"] = 1;
// echoing JSON response
echo json_encode($response);
} else {
// no products found
$response["success"] = 0;
$response["message"] = "No products found";
// echo no users JSON
echo json_encode($response);
}
}
else {
// required field is missing
$response["success"] = 0;
$response["message"] = "Required field(s) is missing";
// echoing JSON response
echo json_encode($response);
}
mysql_close();
?>
回答by Louhbo
I had this error as well. I fixed it by running
我也有这个错误。我通过运行修复了它
mysql_upgrade -u root -p
Also, restart the mysql service by running
另外,通过运行重新启动mysql服务
service mysqld restart
回答by Federico Razzoli
This error happens when a bad upgrade is done. For example, it happens if you upgrade from 5.0 to 5.1 but don't run the mysql_upgrade script; or, in rare cases, it probably happens if you directly upgrade from 5.0 to 5.5. (Many people does this, but such updrages are not officially supported) You say you are using a hosting service - well, I think that you should create a ticket and tell them about the problem. If you don't have the SUPER privilege, there is nothing you can do. But if you have that right, simply run mysql_upgrade: http://dev.mysql.com/doc/refman/5.1/en/mysql-upgrade.html
当升级失败时会发生此错误。例如,如果您从 5.0 升级到 5.1 但不运行 mysql_upgrade 脚本,就会发生这种情况;或者,在极少数情况下,如果您直接从 5.0 升级到 5.5,可能会发生这种情况。(很多人都这样做,但这种升级不受官方支持)您说您正在使用托管服务 - 好吧,我认为您应该创建一张票并告诉他们问题。如果您没有 SUPER 特权,您将无能为力。但如果你有这个权利,只需运行 mysql_upgrade:http://dev.mysql.com/doc/refman/5.1/en/mysql-upgrade.html
回答by XXJECODEXX
I had the same problem when I updated XAMPP from xampp-osx-7.2.10 to 7.3.9 in MacOS Mohave. So the solution was:
我在 MacOS Mohave 中将 XAMPP 从 xampp-osx-7.2.10 更新到 7.3.9 时遇到了同样的问题。所以解决方案是:
Find the file mysql_upgrade in "Macintosh HD? ? ?Applications? ? ?XAMPP? ? ?xamppfiles? ? ?bin?" and double click on it.
在“Macintosh HD???应用程序???XAMPP???xamppfiles???bin?”中找到文件mysql_upgrade 并双击它。
回答by Correcter
I had the same problem when I updated the mysql server from 5.5 to 5.7 in Debian 8 (jessie). In my case, it worked fine when I executed the follow command:
当我在 Debian 8 (jessie) 中将 mysql 服务器从 5.5 更新到 5.7 时遇到了同样的问题。就我而言,当我执行以下命令时它工作正常:
mysql_upgrade --force -uroot -p
Hope it will help you
希望它会帮助你
回答by Joe White
Although you may be correct about the necessity for upgrade, that's not the only reason this error occurs.
尽管您对升级的必要性可能是正确的,但这并不是发生此错误的唯一原因。
When the following is called with a query that returns 1 row
当使用返回 1 行的查询调用以下内容时
my $rv = $sth_indexq->fetchall_arrayref;
the following error is reported:
报告以下错误:
DBD::mysql::st execute failed: Column count of mysql.proc is wrong. Expected 20, found 16. Created with MySQL 50520, now running 50528. Please use mysql_upgrade to fix this error. at
...
However, the real cause of the error was use of fetchall_arrayref instead of fetchrow_arrayref. The following worked without errors:
但是,错误的真正原因是使用了 fetchall_arrayref 而不是 fetchrow_arrayref。以下工作没有错误:
my $rv = $sth_indexq->fetchrow_arrayref;
The data in $rvwas only 1 level deep, not 2.
$rv 中的数据只有1 级深,而不是 2。
The mysql_upgrade solution may very well solve this issue, but the simple solution is know your data and use the right retrieval code.
mysql_upgrade 解决方案可能很好地解决了这个问题,但简单的解决方案是了解您的数据并使用正确的检索代码。
J.White
怀特