文章介绍了关于mysqlnd cannot connect to MySQL 4.1+ using the old insecure authentication方法,有需要了解的同学可参考一下。

Warning: mysql_connect() [.mysql-connect]: Premature end of data (mysqlnd_wireprotocol.c:554) in path/to/the/file/where/connection/script/is/written/

Warning: mysql_connect() [function.mysql-connect]: OK packet 1 bytes shorter than expected in path/to/the/file/where/connection/script/is/written/

Warning: mysql_connect() [function.mysql-connect]: mysqlnd cannot connect to MySQL 4.1+ using the old insecure authentication. Please use an administration tool to reset your pass 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 path/to/the/file/where/connection/script/is/written/

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.chajian8.com' ) WHERE User = 'chajian8' LIMIT 1 ;

SELECT LENGTH( PASSWORD ) FROM mysql.user WHERE User = 'chajian8';

FLUSH PRIVILEGES ;

附 PHP连接MySQL测试代码:

代码如下

复制代码

本文原创发布php中文网,转载请注明出处,感谢您的尊重!

cannot+connect+mysql_mysqlnd cannot connect to MySQL 4.1+ using the old insecure相关推荐

  1. CentOS connect:fail, reason: connect server 22 port fail

    CentOS connect:fail, reason: connect server 22 port fail 分析原因: 连接端口22 失败 (1) 端口原因:明显对外开放的端口并没有打开 ipt ...

  2. AS构建失败,提示Cause:connect timed out Connect to marven.google.com...connect time out

    问题描述: 从github上下载Android O的app项目学习,导入到AS后启动构建失败,提示提示Cause:connect timed out Connect to marven.google. ...

  3. android connect 闪退,Connect闪退

    您好, 了解到您在使用Connect应用时遇到问题. 请问您目前使用的是Windows 10 的哪个版本?可以尝试在搜索框中搜索about,点击电脑信息,查看一下版本信息. 可以尝试使用下面链接中的疑 ...

  4. easy connect 获取服务端配置信息失败_如何统计 Mysql 服务器状态信息?

    最近在看<高性能的 Mysql>一书,下面是关于如何学习统计 Mysql 服务器状态的学习总结,主要是学习使用 SHOW STATUS,SHOW ENGINE INNODB STATUS, ...

  5. SELinux导致PHP连接MySQL异常Can't connect to MySQL server的解决方法

    2019独角兽企业重金招聘Python工程师标准>>> 同事报告一起奇怪的现象,一个最简单的测试PHP代码,在测试环境很正常,但是在正式环境下,无论用何种方式(tcp/ip.unix ...

  6. PHP下的Oauth2.0尝试 - OpenID Connect

    OpenID Connect OpenID Connect简介 OpenID Connect是基于OAuth 2.0规范族的可互操作的身份验证协议.它使用简单的REST / JSON消息流来实现,和之 ...

  7. python通过connect对象连接数据库对吗_Python连接数据库学习之DB-API详解

    前言 大家都知道在Python中如果要连接数据库,不管是MySQL.SQL Server.PostgreSQL亦或是SQLite,使用时都是采用游标的方式,所以就不得不学习Python DB-API. ...

  8. cdc工具 postgresql_SQLServer CDC数据通过Kafka connect实时同步至分析型数据库 AnalyticDB For PostgreSQL及OSS-阿里云开发者社区...

    背景 SQLServer为实时更新数据同步提供了CDC机制,类似于Mysql的binlog,将数据更新操作维护到一张CDC表中. 开启cdc的源表在插入INSERT.更新UPDATE和删除DELETE ...

  9. Kafka Connect使用教程

    1 kafka connect是什么 根据官方介绍,Kafka Connect是一种用于在Kafka和其他系统之间可扩展的.可靠的流式传输数据的工具.它使得能够快速定义将大量数据集合移入和移出Kafk ...

  10. kafka Java客户端之Connect API

    kafka Connect 简单介绍 Kafka Connect 是一个可扩展.可靠的在Kafka和其他系统之间流传输的数据工具.它可以通过connectors(连接器)简单.快速的将大集合数据导入和 ...

最新文章

  1. 饿了么四年、阿里两年:研发路上的一些总结与思考
  2. Q2财报凸显“服务”,“巨人”百度正在转身
  3. 七十三、Python | Leetcode数字系列(上篇)
  4. em模型补缺失值_基于EM算法数据单变量缺失处理方法研究
  5. mybatisplus 一次性执行多条SQL语句插入(Mysql篇)
  6. RabbitMQ 集群搭建_02_rpm版本(linux环境)
  7. 2008最新热门搞笑的50条语录
  8. php html页面获取session,怎么在html中获取session变量
  9. 关于计算机实验的英语作文,关于实验的英语作文
  10. 京东助手+淘宝试用助手+苏宁试用助手软件
  11. LC振荡器的工作原理
  12. 【毕设记录日记】Python基础内容笔记整理6:函数
  13. mysql中getdate怎么用_SQL中 getdate() 用法
  14. 用python画年度和月度的日历图
  15. 国产自主内存产能发展迅猛
  16. Elasticsearch 组合聚集(Composite aggregation)实现交叉分析
  17. 西电计算机学院崔江涛,“师德标兵”崔江涛:人才培养的研究者与实践者
  18. Python中5种下划线的含义
  19. 美元兑人民币今天涨156个基点达到6.4044,人民币是否会持续贬值???
  20. OmniPlan 3 Pro for Mac 3.14.4项目管理工具

热门文章

  1. apache启动不了
  2. ubuntu openStack icehouse dashboard theme自定义
  3. oracle 9i、10g、11g、12c官方文档
  4. linux网络客户端命令
  5. iphone GCDAsyncSocket 详解
  6. 16.深入分布式缓存:从原理到实践 --- 新的旅程
  7. 6.数据结构 --- 树和二叉树
  8. 30.Linux/Unix 系统编程手册(上) -- 线程:线程同步
  9. Struts中提示Invalid result location value/parameter
  10. 【Social listening实操】作为一个合格的“增长黑客”,你还得重视外部数据的分析!...