2013-04-23 34 views
12

我使用000webhost.com,我在那裏使用phpMyAdmin。我從MySQL運行我的PHP腳本時出現這個錯誤,如標題所示:mysql.proc的列數錯誤。預計20,找到16.表可能損壞

mysql.proc的列計數錯誤。預計20個,找到16個。

該表可能已損壞。

有沒有解決方案?謝謝。

編輯:這裏是我的代碼

<?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(); 
?> 
+0

提供一些更多的細節將是一個良好的開端:對我來說,當我執行的後續命令工作得很好。你正在運行一個存儲過程嗎? UDF?如何顯示你想要運行的一些代碼?我們很好,但我們不是通靈,不能閱讀你的想法或遠程查看你的屏幕。 – 2013-04-23 19:23:26

+0

哦,你是對的,我把代碼儘可能快。我只是不能連接到000webhost.com.I會發布它。謝謝:) – user2086258 2013-04-23 19:24:55

+0

http://dba.stackexchange.com/questions/956/resolving-issue-with-mysql-proc-after-upgrading-mysql-from-5-0-to-5-1 – 2013-04-23 19:45:02

回答

10

時壞升級完成後會發生這種錯誤。例如,如果您從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

+1

運行'mysql_upgrade -u root -p'爲我解決了我的數據庫問題。謝謝。 – jorisw 2017-05-30 11:59:08

1

雖然你可能是對的必要性,升級是正確的,這不是發生這個錯誤的唯一原因。

當以下是調用返回報道1個

my $rv = $sth_indexq->fetchall_arrayref; 

以下錯誤的查詢:

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 
... 

但是,錯誤的真正原因是使用fetchall_arrayref代替fetchrow_arrayref。下面沒有錯誤的工作:在$ RV

my $rv = $sth_indexq->fetchrow_arrayref; 

數據僅爲1級深,而不是2

mysql_upgrade解決方案可能很好地解決了這個問題,但簡單的解決方案是知道你的數據並使用正確的檢索代碼。

J.White

+0

總是用代碼格式化,如果你寫了一些代碼,使用ctrl + k。 「 – Hamad 2013-11-19 20:19:11

+1

」知道你的數據「:true,但是mysql.proc不是我們的數據(並且花了我數小時,太多時間才注意到......) – 2014-10-24 05:54:47

25

我也有這個錯誤。我通過運行

mysql_upgrade -u root -p 

而且固定它,通過運行

service mysqld restart 
+0

這應該是被接受的答案。 – supersan 2017-06-01 18:59:09

+0

tnx多,你救了一天! – 2017-07-14 11:35:53

0

重新啓動mysql服務我有同樣的問題,當我在Debian的8(傑西)更新MySQL服務器,從5.5到5.7。

mysql_upgrade --force -uroot -p 

希望它會幫助你