您的网站程序调试完成并上传到云虚拟主机后,连接云虚拟主机数据库时,提示MySQL数据库版本错误。本文介绍这种情况的可能原因和解决方案。

问题现象

当您完成网站程序的调试并上传到云虚拟主机后,连接云虚拟主机数据库时,系统提示MySQL数据库版本错误。

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

可能原因

您在本地主机的测试环境中使用的MySQL版本为4.1,云虚拟主机提供的MySQL版本为5.1。您没有及时更换PHP版本和MySQL数据库的数据加密方式以匹配MySQL 5.1的运行要求。

解决方案

  1. 更换云虚拟主机的PHP版本。
    1. 登录云虚拟主机管理页面
    2. 找到报错的云虚拟主机,单击对应操作列的管理
    3. 在左侧导航栏,选择高级环境设置 > PHP版本设置
    4. PHP版本设置页面,将PHP版本设置为PHP 5.3,然后单击保存设置
  2. 设置41位加密模式。
    1. 在左侧导航栏,单击数据库信息
    2. 数据库信息页面,单击重置密码
    3. 在弹出的数据库密码重置对话框,将新密码设置为网站程序配置文件中的数据库密码,加密模式设置为41位,然后单击确认
  3. 再次连接云虚拟主机数据库。
    如果问题仍未解决,请提交工单