php连接mysql mysqlnd cannot connect to MySQL 4.1+ us

密码字节数的问题,设置 old_passwords=0 即可解决;

在 mysql的my.ini文件中将old_passwords=1 修改为 0;

或者 set old_passwords =0;

一、修改以前的:

mysql> SELECT user, Length(`Password`) FROM `mysql`.`user`; 
+------+--------------------+
| user | Length(`Password`) |
+------+--------------------+
| root |                 16 |
| root |                  0 |
|      |                  0 |
| test |                 16 |
| test |                 16 |
+------+--------------------+
5 rows in set

二、修改 old_passwords;

mysql> set old_passwords=0;
Query OK, 0 rows affected

三、修改用户:

mysql> UPDATE mysql.user SET Password = PASSWORD( 'snow @wolf ') WHERE user = 'root
';
Query OK, 2 rows affected
Rows matched: 2  Changed: 2  Warnings: 0
Query OK, 0 rows affected

四、查看:

SELECT user, Length(`Password`) FROM `mysql`.`user`; 
+------+--------------------+
| user | Length(`Password`) |
+------+--------------------+
| root |                 41 |
| root |                 41 |
|      |                  0 |
| test |                 16 |
| test |                 16 |
+------+--------------------+
5 rows in set

 

可以看到已经更新成功了,将其他用户都更新了即可。

你可能感兴趣的:(php连接mysql mysqlnd cannot connect to MySQL 4.1+ us)