【问题标题】:Mysql password Error in PHPPHP中的Mysql密码错误
【发布时间】:2011-04-16 14:18:17
【问题描述】:

当我尝试从本地主机连接远程 mysql 服务器时,我收到此错误:

Could not connect: 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

知道为什么会出现这个错误吗?

【问题讨论】:

标签: php mysql xampp


【解决方案1】:

它给出了这个错误,因为您的 MySQL 服务器使用 old 存储密码的方式——而不是 new 方式,这种方式更安全。

php 5.3 引入的mysqlnd 驱动不支持旧的认证方式。

因此,您必须修改您的 MySQL 配置,以使用新的、更安全的方式。
您收到的错误消息指示您如何执行此操作。

【讨论】:

    【解决方案2】:

    这对我有帮助

    http://www.phpro.org/articles/Database-Connection-Failed-Mysqlnd-Cannot-Connect-To-MySQL.html

    快速修复

    作为数据库用户

    SET SESSION old_passwords=0; 
    SET PASSWORD=PASSWORD('my_password');
    

    作为管理员

    FLUSH PRIVILEGES;
    

    真正的修复

    打开您的 my.conf 文件并注释掉以下行

    old_passwords=1
    

    重启 MySQL。这将确保 MySQL 不再使用旧密码。

    作为数据库用户

    SET PASSWORD=PASSWORD('my_password');
    

    作为管理员

    FLUSH PRIVILEGES;
    

    【讨论】:

      【解决方案3】:

      在 PHP 5.3+ 中运行 PHP http://forums.mysql.com/read.php?52,403493,411125#msg-411125

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 2023-03-23
        • 2011-07-09
        • 1970-01-01
        • 1970-01-01
        • 2019-06-19
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多