简体   繁体   English

mysql传输使用password()散列的密码

[英]mysql transfer passwords hashed with password()

I am trying to transfer a big MySQL database which hash tables with Users and their credentials 我正在尝试转移一个大型的MySQL数据库,该数据库使用用户及其凭据散列表

The passwords of the users which are stored in those tables are stored with the MySQL password() method. 存储在这些表中的用户密码使用MySQL password()方法存储。 Upon transferring them to the new machine, it seems that the hashed passwords are no longer valid. 将它们转移到新计算机上后,哈希密码似乎不再有效。

Is there any way to transfer password() encrypted fields to the new server with them working properly? 有什么方法可以将password()加密的字段正确地传输到新服务器? Thanks 谢谢

* EDIT * *编辑*

I was indeed facing compatibility issues. 我确实确实遇到了兼容性问题。 My MySQL version was generating 16-byte hash passwords, however the new version of MySQL I installed was using the new 41-byte hashing method. 我的MySQL版本生成16字节的哈希密码,但是我安装的MySQL的新版本使用的是新的41字节哈希方法。

However, I've found a solution, 但是,我找到了解决方案,

I've set old_passwords=1 in the my.cfg MySQL config then, the new version of mysql will use the old hashing of passwords. 我已经在my.cfg MySQL配置中设置了old_passwords=1 ,然后,新版本的mysql将使用旧的密码哈希。 However, I don't recommend anyone to do this because the new hashing method of newer mysql servers is better and safer. 但是,我不建议任何人这样做,因为更新的mysql服务器的新哈希方法更好,更安全。 Sadly, I cannot do this because I have more than 100 applications on the server 遗憾的是,我无法执行此操作,因为服务器上有100多个应用程序

The best solution is provided by dlyaza above. 上面的dlyaza提供了最好的解决方案。

You are facing compatibility issues for MySQL password() function, please read this article in detail: 6.1.2.4 Password Hashing in MySQL . 您面临MySQL password()函数的兼容性问题,请详细阅读本文: 6.1.2.4 MySQL中的密码哈希

In short, MySQL provides old_password() for compatibility when moving from old server to new server. 简而言之,当从旧服务器迁移到新服务器时,MySQL提供了old_password()兼容性。 Therefore, for new server, you could use: 因此,对于新服务器,您可以使用:

SELECT old_password('test')

Procedure to fix this issue: 解决此问题的过程:

  1. add new filed in the table as password2 or any name. 在表中添加新文件作为password2或任何名称。
  2. Use old_password() for authenticating user on new server, if the password is valid, then save a copy in the field that created at step 1. 如果密码有效,请使用old_password()对新服务器上的用户进行身份验证,然后将副本保存在步骤1中创建的字段中。
  3. once you converted all user passwords, then you can use password() normally. 一旦转换了所有用户密码,便可以正常使用password()了。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM