php聯結不上mysql,但Nvicat可以

來源:互聯網
上載者:User
php串連不上mysql,但Nvicat可以。
$db=mysql_connect("124.172.118.122", "dbcms_f","123456");
if (!$db)
{
die('
串連錯誤: ' . mysql_error());
}
$sqlname="dbcmxs";//資料庫的名
mysql_select_db($sqlname,$db)or die ("連結錯誤!! ");//串連到資料庫
session_start();
mysql_query("SET NAMES 'utf8'",$db);//定義資料互動的語言格式

錯誤資訊是

Warning: mysql_connect() [function.mysql-connect]: Premature end of data (mysqlnd_wireprotocol.c:553) in D:\workspace\php\fww\phpcms\inc\conn.php on line 2

Warning: mysql_connect() [function.mysql-connect]: OK packet 1 bytes shorter than expected in D:\workspace\php\fww\phpcms\inc\conn.php on line 2

Warning: mysql_connect() [function.mysql-connect]: mysqlnd cannot connect to MySQL 4.1+ using the old insecure authentication. Please use an administration tool to reset your password with the command SET PASSWORD = PASSWORD('your_existing_password'). This will store a new, and more secure, hash value in mysql.user. If this user is used in other scripts executed by PHP 5.2 or earlier you might need to remove the old-passwords flag from your my.cnf file in D:\workspace\php\fww\phpcms\inc\conn.php on line 2

串連錯誤: mysqlnd cannot connect to MySQL 4.1+ using the old insecure authentication. Please use an administration tool to reset your password with the command SET PASSWORD = PASSWORD('your_existing_password'). This will store a new, and more secure, hash value in mysql.user. If this user is used in other scripts executed by PHP 5.2 or earlier you might need to remove the old-passwords flag from your my.cnf file

下面的是我遠程mysql的資訊
伺服器版本: 5.5.20
Protocol version: 10
伺服器: Localhost via UNIX socket
使用者: *****)[email protected]
MySQL 字元集: cp1252 West European (latin1)

建立一個新的資料庫:
無許可權


MySQL PHP 資料庫 伺服器


------解決方案--------------------
警告:MYSQL_CONNECT()[function.mysql串連]:D中的資料過早結束(mysqlnd_wireprotocol.c:553):\工作區\ PHP\ INC \ conn.php\ FWW\ PHPCMS上線2

警告:MYSQL_CONNECT()[串連]:OK包1個位元組少於預期在D:\工作區\ PHP\ FWW\ PHPCMS\ INC \ conn.php2號線

警告:MYSQL_CONNECT()[function.mysql串連的mysqlnd無法串連到MySQL4.1+使用舊的不安全的認證。請使用管理工具來重設您的密碼命令SET PASSWORD =的密碼('your_existing_password')。這將儲存在mysql.user一個新的,更安全,雜湊值。如果此使用者使用其他指令碼執行PHP5.2或更早版本,你可能需要刪除舊密碼標誌2號線從my.cnf檔案在D:\ workspace下,\ php\ FWW的\ PHPCMS\ INC\ conn.php

串連錯誤的mysqlnd無法串連到MySQL4.1+使用舊的不安全的認證。請使用管理工具來重設您的密碼命令SET PASSWORD =的密碼('your_existing_password')。這將儲存在mysql.user一個新的,更安全,雜湊值。如果此使用者執行在其他指令碼中使用PHP5.2或更早版本,你可能需要從你的my.cnf檔案刪除舊密碼標誌

是你的 php 版本太低,還是 mysql 版本太高
------解決方案--------------------
按錯誤資訊看,應該是php所帶的mysql用戶端版本太低了
  • 聯繫我們

    該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

    如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.