错误:mysqlnd 无法连接到 MySQL 4.1+使用旧的不安全身份验证
我收到以下错误:
数据库连接失败:mysqlnd 无法使用旧的不安全身份验证连接到 MySQL 4.1+。请使用管理工具通过命令
SET PASSWORD = PASSWORD('your_existing_password')
重置您的密码。这将在
mysql.user
中存储一个新的、更安全的哈希值。如果这个 user 用于 PHP 5.2 或更早版本执行的其他脚本中,您可能会 需要从您的my.cnf
文件中删除旧密码标志
我在本地计算机上使用 PHP 5.3.8 和 MySQL 5.5.16,并且我的主机(媒体寺庙)正在运行 PHP 5.3 MySQL 5.0。 51a.实时服务器上的版本比我机器上的版本旧。
如何修复此错误并从本地计算机连接到 MySQL?
我知道有与此类似的帖子,但我已经尝试过所有帖子,但没有一个起作用。
I am getting the following error:
Database connection failed: 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 yourmy.cnf
file
I using PHP 5.3.8 and MySQL 5.5.16 on my local machine and my host (media temple) is running PHP 5.3 MySQL 5.0.51a. The version on the live server is older than the one on my machine.
How do I fix this error and connect to MySQL from my local machine?
I know there are similar posts to this one but I have tried them all and none are working.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(7)
重新启动 MySQL。如果不这样做,MySQL 将继续使用旧的密码格式,这意味着您无法使用内置的 PASSWORD() 哈希函数升级密码。
旧密码哈希值是 16 个字符,新密码哈希值是 41 个字符。
连接到数据库,并运行以下查询:
这将显示哪些密码采用旧格式,例如:
请注意,每个用户可以有多行(每个不同的主机规范对应一个) 。
要更新每个用户的密码,请运行以下命令:
最后,刷新权限:
来源:如何修复“mysqlnd 无法使用旧身份验证连接到 MySQL 4.1+” PHP5.3
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.
The old password hashes are 16 characters, the new ones are 41 characters.
Connect to the database, and run the following query:
This will show you which passwords are in the old format, e.g.:
Notice here that each user can have multiple rows (one for each different host specification).
To update the password for each user, run the following:
Finally, flush privileges:
Source: How to fix "mysqlnd cannot connect to MySQL 4.1+ using old authentication" on PHP5.3
我遇到了一个问题,服务器默认启用旧密码,因此一个简单的 SET PASSWORD FOR 'some-user'@'%' = PASSWORD ('XXXX');不起作用(由于旧软件和遗留问题,我不会讨论......)
解决方案:
详细信息:
以登录用户身份执行此操作
根本不起作用,例如
可在此处测试
密码不会改变从
旧密码
我想要什么,例如新密码
所以我查找了旧密码的变量
所以基本上我必须先将mysql服务器var设置为old_password=OFF,例如这对我有用
I had a issue where the old passwords had been enable by the server by default, so a simple SET PASSWORD FOR 'some-user'@'%' = PASSWORD ('XXXX'); wouldn't work(for reason due to old software and legacy which I won't go into....)
Solution :
Details :
Doing this as the logged in user
Simply didn't work
Eg testable here
The password wouldn't shift to from
OLD PASSWORD
WHAT I WANTED, EG NEW PASSWORD
So I looked up the variables for old passwords
So basically I had to set the mysql server var first to old_password=OFF, eg this worked for me
我在尝试通过本地 Windows 计算机上的 IIS 连接到 mediatemple external-db 时遇到了同样的问题。更新特定数据库用户的密码解决了连接到数据库的问题。
在 (mt) 帐户中心内,只需更新密码即可。我使用了相同的密码,它解决了我所有的问题。
I had the same issue trying to connect to mediatemple external-db through IIS on my local Windows machine. Updating my password for the specific db user solved the problem connecting to the database.
Within (mt) Account center, simply update the password. I used the same password and it solved all my problems.
配置目标 Mysql 服务器以允许旧的不安全身份验证。
http://dev.mysql.com/doc /refman/5.0/en/server-options.html#option_mysqld_old-passwords
只需在目标 Mysqld 服务器上的 my.cnf 文件中注释掉 old_passwords 即可。
也许有办法获得使用兼容(旧)身份验证模式的 PHP 构建(或自己构建)。
Configure target Mysql server to allow old insecure auth.
http://dev.mysql.com/doc/refman/5.0/en/server-options.html#option_mysqld_old-passwords
Simply in the my.cnf file on target Mysqld server comment out the old_passwords.
Maybe there is way to obtain PHP build (or build it yourself) which uses compatible (old) auth mode.
我第一次在网格服务器上使用 Media Temple 数据库时遇到此错误。
导致此问题的原因是我使用的数据库用户密码仍采用旧密码格式。新格式需要 10 多个字符、特殊字符、数字等...
我以新格式创建了一个新的数据库用户和密码,并且运行良好。
I ran into this error for the first time with a Media Temple db on a grid server.
The issue was caused because I used a password for a database user that was still in their old password format. The new format calls for 10+ characters, special characters, a number etc...
I created a new database user and password in the new format and it worked fine.
当我从旧版本的 MySQL 导入数据库时,我遇到了这个问题。最大的问题 - 它阻止我使用 root 用户连接到 MySQL,因此我必须按照以下说明
重置 root 密码
:此后,我能够应用上面给出的修复程序。
例如通过:
I had this issue when I imported a database from an older version of MySQL. The biggest problem - it was preventing me from connecting to MySQL with my root user, so I had to
reset the root password
by following the instructions below:After this I was able to apply the fix given above.
E.g. by:
我有同样的问题,这是我为解决此问题所做的所有步骤:
<块引用>
更新 mysql.user SET 密码 = PASSWORD('NewPassword') WHERE user = '用户名';
i have the same issue and this is all steps i've done to solve this porbleme :