3

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?

user3909208
  • 71
  • 1
  • 2
  • 7
  • It's mysql function, not phpmyadmin. Try to run SQL: `UPDATE table SET column = MD5('yourpassword')`, and see what happend. – michail_w Aug 17 '14 at 18:54
  • 1
    You should not use `md5` hashes to store passwords: http://stackoverflow.com/questions/401656/secure-hash-and-salt-for-php-passwords?rq=1 – jeroen Aug 17 '14 at 18:57
  • Please comment on the link I provided.. – user3909208 Aug 18 '14 at 05:53
  • @user3909208 - Also hash algorithms of the SHA-* family are not appropriate to hash passwords. You can e.g. test about [3 Giga SHA-1 hashes per second](http://hashcat.net/oclhashcat/#performance) with common hardware, and the missing salt is still a problem. – martinstoeckli Aug 18 '14 at 07:31

3 Answers3

6

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

UPDATE table_name SET 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

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"

UPDATE userdetails SET pass = MD5('12345678') WHERE 'user_id' = 1

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

And your password of user_id = 1 will be encrypted as25d55ad283aa400af464c76d713c07ad

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.

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.

Jheel Agrawal
  • 644
  • 6
  • 6
0

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

  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');

Branko Sego
  • 780
  • 6
  • 13
0

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.

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().

martinstoeckli
  • 23,430
  • 6
  • 56
  • 87