简体   繁体   English

使用大约50000条记录更新表的所有行上的特定字段

[英]update a specific field on all rows of a table with about 50000 records

i have a table that holds my users information like username , password , name , family , etc. already when a user register in my site her password hashes with one md5() function then insert into table. 我有一个表,用于保存我的用户信息,如用户名,密码,姓名,家庭等,当用户在我的网站注册时,她的密码哈希与一个md5()函数然后插入表。 my table have about 50000 records now. 我的桌子现在有大约50000条记录。 but now i want to hash their passwords with two md5() function again for security issues. 但现在我想再次使用两个md5()函数来散列他们的密码以解决安全问题。 for that i write below code that first selects all of the users and then execute a update Query for change passwords: 为此我写下面的代码,首先选择所有用户,然后执行更新查询更改密码:

$allMembers =   mysql_query("select `username`,`password` from `members`",$conn);


if (mysql_num_rows($allMembers) > 0){

    while($row  =   mysql_fetch_array($allMembers)){

            $oldPass    =   $row['password'];

            $newPass    =   md5(md5('Hello'.$oldPass.'Friends'));

            mysql_query("update `members` set `password`='$newPass' where `username`='".$row['username']."'",$conn);
    }
}

echo("Yes");

but when i run this code It took very little and produce No Data Received message . 但是,当我运行此代码它花了很少,并产生无数据接收消息 but now how i update the password field in my large table ? 但现在我如何更新我的大表中的密码字段?

Edit :i was used salt + md5 but removed it in my code for Summarization :) 编辑 :我使用salt + md5但在我的代码中将其删除为Summarization :)

Just run it as a single query: 只需将其作为单个查询运行:

UPDATE `members` SET `password`=MD5(MD5(`password`))

BTW double MD5 is useless. BTW双MD5没用。 you can MD5 + salt or SHA1 + salt if you want better security. 如果你想要更好的安全性,你可以使用MD5 +盐或SHA1 +盐。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM