我使用XAMPP 在本地主机中收到此警告
Warning: 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 C:'xampp'htdocs'folder'dbconnect.php on line 135
如何修复此警告?它的含义是什么?
转到您的xampp文件夹目录:xampp/htdocs/xampp/mysql.php
你会在页面上找到这个代码:
<?php
if (@mysql_connect("localhost", "pma", "")) {
echo "OK";
} else {
echo "NOK";
}
?>
所以你所要做的就是用下面的代码交换整个代码:
<?php
if (@mysql_connect("localhost", "pma", "")) {
echo "OK";
} else {
$err = mysql_errno();
if ((1044 == $err) || (1045 == $err) || (1130 == $err)) {
echo "OK";
} else {
echo "NOK";
}
}
?>
你的错误很快就解决了!!
登录到XAMPP的PHPMyAdmin并在PHPMyAdmin 中运行以下查询
SET PASSWORD = PASSWORD('your_old_mysql_password')
其中your_old_mysql_password应替换为当前mysql密码。
这应该可以解决你的问题。
您也可以简单地重新安装XAMPP(如果可能的话,安装到另一个目录),这应该可以保证修复,因为它是自包含的。