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。

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

  1. 解决Mysql报错:PHP Warning: mysql_connect(): mysqlnd cannot connect to MySQL 4.1+ using the old insecure authentication.

    最近我更新了appserv-win32-2.5.10的 PHP 5.2版本到PHP 5.3,在调用http://localhost/phpMyAdmin/时,出现如下错误:PHP Warning:   ...

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

    直接命令行操作没有问题,但是PHP连接就会报上面的错误. SET old_passwords =0; USE mysql; UPDATE user SET password =PASSWORD('yo ...

  3. 【转】Warning: mysql_connect(): mysqlnd cannot connect to MySQL 4.1+ using the old insecure authenticat

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

  4. mysqlnd cannot connect to MySQL 4.1+

    phpMyAdmin - error #2000 - mysqlnd cannot connect to MySQL 4.1+ using the old insecure authenticatio ...

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

    第一篇:PHP5.3开始使用MySqlND作为默认的MySql访问驱动,而且从这个版本开始将不再支持使用旧的用户接口链接Mysql了,你可能会看到类似的提示: #2000 - mysqlnd cann ...

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

    MYSQL ERROR 2003 (HY000): Can't connect to MySQL server on '192.168.10.210' (111) 解决方法 今天在测试MySQL的连接 ...

  7. 卸载MySQL以及重装卡到Start Services的解决办法(亲测有效,刚重装成功)

    卸载MySQL以及重装卡到Start Services的解决办法 重装系统永远是个好办法,但是对于我们程序员来说只要一想到电脑上的环境变量和其他的配置就蔫了.所以这一条就当作是废话吧. 一般来说装My ...

  8. MySQL Shell无法拉起MGR集群解决办法

    MySQL Shell无法拉起MGR集群解决办法 用MySQL Shell要重新拉起一个MGR集群时,可能会提示下面的错误信息: Dba.rebootClusterFromCompleteOutage ...

  9. mysqlnd cannot connect to MySQL 4.1+ using old authentication

    报这个错误主要是因为mysql使用了老的密码格式,而程序要求使用新的格式导致的,解决办法: SET old_passwords = 0; UPDATE mysql.user SET Password ...

随机推荐

  1. BZOJ3906 : Trie

    将输入的Trie建成AC自动机,并建出fail树. 那么操作1等价于在给定点的子树的并集里都加1. 操作2等价于查询给定点到根节点路径的并集的权值和. 求出DFS序后,对于操作1,将点按进入时间戳从小 ...

  2. 添加Bootstrap 到MVC项目中(vs2010)

    环境:Visual Studio 2010   ASP.NET MVC3 手动添加: 下载地址:http://twitter.github.com/bootstrap/ 一个js,两个css,两张图 ...

  3. c++ map删除元素

    typedef std::map<std::string,float> StringFloatMap; StringFloatMap col1; StringFloatMap::itera ...

  4. 【BZOJ】1854: [Scoi2010]游戏

    http://www.lydsy.com/JudgeOnline/problem.php?id=1854 题意:n个数据,每个数据有两个属性,要求取一些数据且每个数据取一个属性使得组成连续的一段单调递 ...

  5. Json 数组拼接

    var str1 = {"name": "apple", "sex": "21"};                 / ...

  6. 封装同步的UIActionSheet

    封装同步的UIActionSheet 发问题 做 iOS 开发的同学想必都用过 UIActionSheet.UIActionSheet 可以弹出一个选择列表,让用户选择列表中的某一项操作.使用 UIA ...

  7. iOS开发中常见的问题

      1.重复调用2次loadView和viewDidLoad 最好不要在UIViewController的loadView方法中改变状态栏的可视性(比如状态栏由显示变为隐藏.或者由隐藏变为显示),因为 ...

  8. [ZT] 酒店大洗脑:最全各大国际酒店集团族谱图

    原文地址: http://www.licai.com/yuedu/201411-62884.html 如果你对各大耳熟能详的国际酒店管理集团还有什么问题,相信今天和你分享的各大酒店集团家族系谱图和最全 ...

  9. QCheckBox 的按钮响应

    Qt中QCheckBox的按键响应如下,其中checkbox为对象名: void YourClass::on_checkbox_toggled(bool state) { // Do somethin ...

  10. oracle在线重定义表

    在一个高可用系统中,如果需要改变一个表的定义是一件比较棘手的问题,尤其是对于7×24系统.Oracle提供的基本语法基本可以满足一般性修改,但是对于把普通堆表改为分区表,把索引组织表修改为堆表等操作就 ...