Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to hash passwords in MySQL?

How I will make every password in my user table encrypted(md5()) except one particular row using a single query?

like image 364
santanu Avatar asked Apr 01 '09 05:04

santanu


People also ask

How is password hashing done in MySQL?

In other words, the server checks hash values during authentication when a client first attempts to connect. The server generates hash values if a connected client invokes the PASSWORD () function or uses a password-generating statement to set or change a password. Password hashing methods in MySQL have the history described following.

What is the use of MySQL password function?

The MySQL PASSWORD function is used for the generation of a hashed password using a plain-text password string It uses hashing techniques to generate the hashed password. This function is carried out by the authentication system.

How to encrypt passwords in MySQL?

MySQL server uses the PASSWORD function to encrypt MySQL passwords for storage in the Password column of the user grant table. The value returned by the PASSWORD function is a hashed string, or NULL if the argument was NULL.

What is the password_hash () function in PHP?

The password_hash () function creates a secure hash of your password. This is how you can use it: $password = 'my secret password'; $hash = password_hash($password, PASSWORD_DEFAULT); The result hash from password_hash () is secure because:


1 Answers

UPDATE table SET Password = MD5(Password)

I will say though that MD5 isn't a very good level of encryption and you should consider something stronger such as ENCRYPT with a custom salt. Read about it here

EDIT: Looks like the original question changed. Here's the altered query to accomodate

UPDATE table SET Password = MD5(Password) WHERE ID!=[specified index]

EDIT: Worth noting

MD5 Encryption Hacked

like image 70
jerebear Avatar answered Oct 20 '22 19:10

jerebear