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用戶端版本太低了