mysqlnd cannot connect to MySQL 4.1+ using the old insecure authentication解决办法

mysqlnd是个好东西。不仅可以提高与mysql数据库通信的效率,而且也可以方便的设置一些超时。如,连接超时,查询超时。
但是,使用mysqlnd的时候,有个地方需要注意。就是服务端的密码格式不能使用旧的16位的存储格式,而要使用新的41位的存储格式。
如果,服务端的密码格式是16位,那么就会报错。信息如下:
Fatal error: Uncaught exception ‘PDOException’ with message ‘SQLSTATE[HY000] [2000] 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 /home/hailong.xhl/test.php:8

如何查看自己的密码是否符合要求,so easy。


1

2

3

4

5

6

7

mysql> select user,length(password) from mysql.user;

+--------------+------------------+

| user         | length(password) |

+--------------+------------------+

| demo         |               16 |

| demo         |               16 |

+--------------+------------------+

上面的密码是旧的16位格式。如果想改成新的41位格式,通过以下命令就可以。


1

2

3

4

5

6

7

8

9

10

11

12

mysql>UPDATE mysql.user SET Password = PASSWORD(‘demo‘) WHERE user = ‘demo‘;

Query OK, 2 rows affected (0.00 sec)

Rows matched: 2  Changed: 2  Warnings: 0

mysql> select user,length(password) from mysql.user;

+--------------+------------------+

| user         | length(password) |

+--------------+------------------+

| demo         |               41 |

| demo         |               41 |

+--------------+------------------+

mysql> flush privileges;

Query OK, 0 rows affected (0.00 sec)

修改完密码后,还需要在配置文件中修改下old_passwords选项。把值设置为0。即,
old_passwords=0
然后重启mysql。

时间: 2024-08-10 01:54:06

mysqlnd cannot connect to MySQL 4.1+ using the old insecure authentication解决办法的相关文章

mysql_error:mysqlnd cannot connect to MySQL 4.1+ using the old insecure authentication

SET old_passwords =0; UPDATE mysql.user SET Password =PASSWORD('testpass') WHERE User='testuser' limit 1; SELECT LENGTH(Password) FROM mysql.user WHERE User='testuser'; FLUSH PRIVILEGES;

mysqlnd cannot connect to MySQL 4.1+ using the old insecure authentication的解决方法

直接命令行操作没有问题,但是PHP连接就会报上面的错误. SET old_passwords =0; USE mysql; UPDATE user SET password =PASSWORD('yourpassword') WHERE user='testuser' limit 1; SELECT LENGTH(password) FROM user WHERE user='root'; FLUSH PRIVILEGES;

连接mysql问题 mysqlnd cannot connect to MySQL 4.1+ using old authentication

第一篇:PHP5.3开始使用MySqlND作为默认的MySql访问驱动,而且从这个版本开始将不再支持使用旧的用户接口链接Mysql了,你可能会看到类似的提示: #2000 - mysqlnd cannot connect to MySQL 4.1+ using old authentication 解决问题的方法不是调整PHP,而是检查你的Mysql,你需要确保两件事: 你使用的Mysql是4.1+以上版本,4.1以前的版本只支持使用老的16位密码存储 你准备用于连接的数据库帐号使用的MySql

ERROR 2003 (HY000): Can't connect to MySQL server on '192.168.33.10' (111) 解决方法

谷歌了一下之后,原来是在mysql的my.cnf中有下面一段代码: # Instead of skip-networking the default is now to listen only on # localhost which is more compatible and is not less secure. bind-address = 127.0.0.1 #这里默认监听本地localhost 如果要让mysql监听到其他的地址,可以将bind-address = 127.0.0.1

【LR11】Error -27796: Failed to connect to server"server:port": [10060] Connection timed out错误解决办法

  场景描述:被测系统是发布在远程服务器上的,假设IP是10.10.10.10,端口是8066,那么访问地址是http://10.10.10.10:8066/,在control机器上我设置了IP欺骗. 错误现象:在场景运行时出现大量Action.c(8): Error -27796: Failed to connect to server"server:port": [10060] Connection timed out错误. 官方的troubleshooting: 查看工具的tro

修改mysql字符编码出现Job failed to start解决办法

从网上找到如下资料: $sudo gedit /etc/mysql/my.cnf [client]下添加: default-character-set=utf8 [mysqld]下添加: default-character-set=utf8 然后保存退出 $ /etc/init.d/mysql restart 结果出现了: Since the script you are attempting to invoke has been converted to an Upstart job, you

开启mysql远程访问过程中所遇常见问题的解决办法

今天在测试MySQL的连接时候,发现连接不通过,并报错ERROR 2003 (HY000): Can't connect to mysql server on '192.168.10.210' (111) 测试代码: require 'mysql2' client = Mysql2::Client.new(:host=>"192.168.10.210",:username=>'root',:password=>"root") puts result

mysql最后一步总是未响应的解决办法

http://blog.sina.com.cn/s/blog_86f4502c0101f0rt.html 关于终端访问时不是内部或外部响应解决办法: 如果你打开cmd后直接输入mysql是不行的,需要配置mysql的环境变量,那么就在环境变量中增加D:\MySQL\MySQL_Server_5.5\bin变量名称可以随便起,比方说mysql_home变量值为D:\MySQL\MySQL_Server_5.5\bin这样就可以了直接使用mysql命令了.

转:安装MySQL遇到MySQL Server Instance Configuration Wizard未响应的解决办法

问题:安装了MySQL之后进入配置界面的时候,总会显示“MySQL Server Instance Configuration Wizard未响应”,一直卡死. 解决办法:Win7系统中,以管理员的权限登录系统,将C盘的ProgramData中的MySQL文件夹删掉即可(如果没有该文件夹,可能是因为隐藏了) 转自:http://blog.csdn.net/liuxiyangyang/article/details/8810094 若配置方案选择“Detailed Configuration”的配