我如何加密整个列 [英] how can I encrypt an entire column

查看:60
本文介绍了我如何加密整个列的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在设置邮件服务器,并且我是mysql的密码表.目前,它使用ENCRYPT()函数进行了安全保护,但是我想输入很大的CSV密码(密码均为纯文本).有什么办法可以将它们导入为纯文本,然后运行查询以在整个列上运行ENCRYPT()并更新所有内容?

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?

推荐答案

您可以通过简单的更新来做到这一点:

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

这篇关于我如何加密整个列的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆