php 如何在 phpmyadmin 4.1.6 中添加密码的 md5 哈希?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/25352546/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-25 17:48:03  来源:igfitidea点击:

How to add md5 hash of a password in phpmyadmin 4.1.6?

phpmysqlhashphpmyadmin

提问by user3909208

I am new to phpmyadmin. I wanted to store md5 hash of password in database table without using help of php code. So I found on solution here. But I could not find the option for 'function' in phpmyadmin-4.1.6. How can I achieve my goal?

我是 phpmyadmin 的新手。我想在不使用 php 代码的帮助下将密码的 md5 哈希存储在数据库表中。所以我在这里找到了解决方案。但是我在 phpmyadmin-4.1.6 中找不到“function”的选项。我怎样才能实现我的目标?

回答by Mr. JD Agrawal

For Encrypting password your database with md5() use this query in SQL.

对于使用 md5() 加密您的数据库的密码,请在 SQL 中使用此查询。

UPDATE table_nameSET column_name= MD5('password') WHERE 'column_name' = column_value

UPDATE table_nameSET column_name= MD5('password') WHERE 'column_name' = column_value

Here password in MD5 function is the one which you want to encrypt in your database

这里 MD5 函数中的密码是您要在数据库中加密的密码

For ex: If i have a table called "userdetails" columns for id = "user_id", for email = "email_id", & for password = "pass" and my password is "12345678"

例如:如果我有一个名为“userdetails”列的表,id =“user_id”,email =“email_id”,密码 =“pass”,我的密码是“12345678”

UPDATE userdetailsSET pass= MD5('12345678') WHERE 'user_id' = 1

UPDATE userdetailsSET pass= MD5( '12345678'),其中'USER_ID'= 1

You will get the output printed like 1 row affected in 0.0023 sec

您将在 0.0023 秒内打印出 1 行受影响的输出

And your password of user_id = 1 will be encrypted as25d55ad283aa400af464c76d713c07ad

您的 user_id = 1 密码将被加密为 25d55ad283aa400af464c76d713c07ad

If you now want to check what is your password simply copy the code of password column and google for md5 decrypter or go to this link: http://md5decrypt.net/en/and paste the code and tap on the decrypt button. You will get your password in simple text.

如果您现在想检查您的密码是什么,只需复制密码列的代码和谷歌的 md5 解密器或转到此链接:http: //md5decrypt.net/en/并粘贴代码并点击解密按钮。您将获得简单文本的密码。

Note: md5 encryption is not advisable for sensitive informations & data(s). But if you are just learning database and just simply creating one database for learning purpose you can use md5 encryption.

注意:对于敏感信息和数据,不建议使用 md5 加密。但是如果你只是在学习数据库,只是为了学习目的而只是创建一个数据库,你可以使用 md5 加密。

回答by Branko Sego

It is not phpmyadmin function, it is mysql function, to store password use this code:

它不是 phpmyadmin 函数,它是mysql 函数,存储密码使用以下代码:

  1. To update password

    UPDATE table_name SET column_name= MD5('password) WHERE column_name=column_value;

  2. To insert password into table

    INSERT INTO table_name(column_name) VALUES MD5('password');

  1. 更新密码

    UPDATE table_name SET column_name= MD5('password) WHERE column_name=column_value;

  2. 将密码插入表

    INSERT INTO table_name(column_name) VALUES MD5('password');

回答by martinstoeckli

MySql does not have any appropriate functions to hash a password. MD5 is ways too fast and one should include a random salt. Because of the salt you cannot just recalculate the hash and compare it with the stored hash.

MySql 没有任何适当的函数来散列密码。MD5 太快了,应该包括随机盐。由于盐,您不能只是重新计算散列并将其与存储的散列进行比较。

That said, the hashing of passwords should not be done directly in SQL, instead one should use a server-side language. PHP offers the functions password_hash()and password_verify().

也就是说,密码的散列不应该直接在 SQL 中完成,而应该使用服务器端语言。PHP 提供了password_hash()password_verify()函数。