更新时间:2022-11-27 12:44:40
验证问题是一个已知的问题与PHP 5.3及以上版本的MySQL。检查:
http://www.bitshop.com/Blogs/tabid/95/EntryId/67/PHP-mysqlnd-cannot-connect-to-MySQL-4-1-using-old-authentication.aspx
If I open up a cmd shell and run
>mysql --host=12.34.56.78 --port=1234 --user=myuser --password=mypassword mydb
I can successfully connect to the remote mysql database.
But if I create a php page on my localhost containing
<?php
$hostname = "12.34.56.78:1234";
$username = "myuser";
$password = "mypassword";
$dbname = "mydb";
$connect = mysql_connect($hostname,$username,$password) or die ("Error: could not connect to database");
?>
I get the following error:
Error: could not connect to database
Can anyone explain what might be causing the problem here?
mysql_error() => mysqlnd cannot connect to MySQL 4.1+ using old authentication
Auth problems are a known issue with PHP 5.3 and older versions of MySQL. Check this: