views:

30

answers:

1

Hello All,

I'm setting up a mail server and I'm mysql for the passwords table. Currently it's secured using the ENCRYPT() function however I have a large CSV I'd like to import where the passwords are all plain text. Is there any way I could import these as plain text and then run a query to run ENCRYPT() on the whole column and update everything?

+3  A: 

You can do this with a simple update:

UPDATE your_table SET password_col = ENCRYPT(password_col,'some salt')

Or, if you are using LOAD DATA INFILE to populate the table, you can encrypt the passwords then:

LOAD DATA INFILE '/tmp/data.csv' INTO TABLE your_table 
(col1,...,@password,...,coln) 
set password_col = ENCRYPT(@password,'some salt')
Ike Walker
thanks a bunch, that worked :)
Jonathan