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

本文涉及的产品
云数据库 RDS MySQL Serverless,0.5-2RCU 50GB
简介:

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。


mysql> select user,length(password) from mysql.user; 
+--------------+------------------+
| user         | length(password) |
+--------------+------------------+
| demo         |               16 | 
| demo         |               16 | 
+--------------+------------------+

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


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。


相关实践学习
基于CentOS快速搭建LAMP环境
本教程介绍如何搭建LAMP环境,其中LAMP分别代表Linux、Apache、MySQL和PHP。
全面了解阿里云能为你做什么
阿里云在全球各地部署高效节能的绿色数据中心,利用清洁计算为万物互联的新世界提供源源不断的能源动力,目前开服的区域包括中国(华北、华东、华南、香港)、新加坡、美国(美东、美西)、欧洲、中东、澳大利亚、日本。目前阿里云的产品涵盖弹性计算、数据库、存储与CDN、分析与搜索、云通信、网络、管理与监控、应用服务、互联网中间件、移动服务、视频服务等。通过本课程,来了解阿里云能够为你的业务带来哪些帮助     相关的阿里云产品:云服务器ECS 云服务器 ECS(Elastic Compute Service)是一种弹性可伸缩的计算服务,助您降低 IT 成本,提升运维效率,使您更专注于核心业务创新。产品详情: https://www.aliyun.com/product/ecs
目录
相关文章
|
1月前
|
关系型数据库 MySQL Python
python安装MySQL-python:EnvironmentError解决办法
python安装MySQL-python:EnvironmentError解决办法
31 1
|
5月前
|
SQL 关系型数据库 MySQL
MySQL5.7 group by新特性报错1055的解决办法
MySQL5.7 group by新特性报错1055的解决办法
|
8月前
|
关系型数据库 MySQL 数据安全/隐私保护
远程连接mysql8,报错10061 解决办法
远程连接mysql8,报错10061 解决办法
206 0
|
6月前
|
关系型数据库 MySQL Java
【MySQL异常解决】Operation not allowed when innodb_forced_recovery > 0 的解决办法
【MySQL异常解决】Operation not allowed when innodb_forced_recovery > 0 的解决办法
99 0
【MySQL异常解决】Operation not allowed when innodb_forced_recovery > 0 的解决办法
|
5月前
|
关系型数据库 MySQL
mysql中有大量sleep进程的原因与解决办法
mysql中有大量sleep进程的原因与解决办法
204 0
|
10天前
|
SQL 关系型数据库 MySQL
mysql主从同步出错解决办法
mysql主从同步出错解决办法
7 0
|
1月前
|
关系型数据库 MySQL Java
IDEA+Mysql调试常见异常解决办法_kaic
IDEA+Mysql调试常见异常解决办法_kaic
|
2月前
|
关系型数据库 MySQL 数据库
连接mysql报Access denied for user 'root'@'localhost'错误的解决办法
连接mysql报Access denied for user 'root'@'localhost'错误的解决办法
|
6月前
|
SQL 数据可视化 关系型数据库
【MySql】MySQL排序分页查询数据顺序错乱的原因和解决办法
【MySql】MySQL排序分页查询数据顺序错乱的原因和解决办法
305 0
|
3月前
|
SQL 存储 关系型数据库
MySQL - order by 出现 using filesort根因分析及优化
MySQL - order by 出现 using filesort根因分析及优化
55 0