Warning: mysql_connect(): mysqlnd cannot connect to MySQL 4.1+ using the old insecure authentication

 程序弄好后,[本人乐意黎]将数据传递到万网的虚拟主机,由于我本机用php代码来连接服务器数据库,但总是抛如下错误:

Warning: mysql_connect(): mysqlnd cannot connect to MySQL 4.1+ using the old insecure authentication_第1张图片

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 K:\WEB_2013\www.aerchi.com\***\***.php


百思不得其解。

Google了许久,终于发现了解决办法。 将主机的密码设成41位。

A 万网主机空间,请按以下操作:

将密码设置成41位,即可。
登录主机:
Warning: mysql_connect(): mysqlnd cannot connect to MySQL 4.1+ using the old insecure authentication_第2张图片

===============================================================================================

其它的解决办法:

【乐意黎原创, 禁止采集和转载】

然后将本地数据库的内容导入到网站的数据库中,结果就出现了如下错误信息:

Warning: mysql_connect(): mysqlnd cannot connect to MySQL 4.1+ using the old insecure authentication.

 

这个问题主要就是因为数据库的登陆密码编码问题,对于我们这种小站站长来说,没有虚拟服务器,更没有服务器,只有虚拟空间和有限的数据库操作权限,所以网上说的那些什么改这改那都不能用啊,更不用说联系空间服务商升级数据库了。

其实这个问题的解决办法很简单。一般情况下,虚拟的空间服务商的数据库都提供了phpMyAdmin的MySQL数据库管理工具,所以我们只要在phpMyAdmin中运行下面的两句SQL语句就行了。

SET-SESSION-old_passwords-=-FALSE;
SET-PASSWORD-=-PASSWORD('your-existing-password-in-plain-text');

不信你试试看就知道了。

用的时候将SET后面的连字符’-‘用空格替换掉就可以了,我这个博客的恶心空间服务商给装了信息过滤系统,所以直接发不了。


-------------------------------------------------------------------------------

1. Change MySQL to NOT to use old_passwords
It seems that even MySQL 5.x versions still default to the old password hashes. You need to change this in “my.cnf” (e.g. /etc/my.cnf): remove or comment out the line that says
old_passwords = 1
 //
old_passwords = 1为16位
//所以这里要先
/
/SET old_passwords = 0;
//这样使新密码的长度也变成41位
Restart MySQL. If you don’t, MySQL will keep using the old password format, which will mean that you cannot upgrade the passwords using the builtin PASSWORD() hashing function. You can test this by running:


具体原因我还不是很清楚,跟old密码长度有关?先记录下来,日后研究。解决方法如下:

SET old_passwords = 0;
UPDATE mysql.user SET PASSWORD = PASSWORD( 'www.aerchi.com' ) WHERE User = 'aerchi' LIMIT 1 ;
SELECT LENGTH( PASSWORD ) FROM mysql.user WHERE User = 'aerchi';
FLUSH PRIVILEGES ;


附 PHP连接MySQL测试代码:


<?php
$con = mysql_connect("192.168.3.240:3306","aerchi",www.aerchi.com);
if (!$con)
{
 die('Could not connect: ' . mysql_error());
}
?>



【乐意黎原创, 禁止采集】

本文地址:http://blog.csdn.net/aerchi/article/details/45949937

你可能感兴趣的:(Warning: mysql_connect(): mysqlnd cannot connect to MySQL 4.1+ using the old insecure authentication)