本文目錄一覽:
mysql 密碼加密
1.mysqladmin -uxxx -p password “newpassword”;
這個方法win下不好用
2.進入mysql後
set password for ‘用戶名’@’hostname’ identified by ‘newpassword’;
3.進入mysql後
grant usage on *.* to ‘用戶名’@’hostname’ identified by ‘newpassword’;
4.修改user表
use mysql;
update user set password=password(‘newpassword’) where user=’xxxx’;
mysql資料庫裡面的數據中的密碼加密了,怎麼解密
mysql -uroot -p 輸入密碼回車後,出現如下圖錯誤。這時候需要我們破解密碼。
service mysqld stop //先停止mysql服務。
然後打開mysql配置文件/etc/my.cnf.在【mysqld】下面添加一行代碼:skip-grant-tables。這行代碼意思就是跳過跳過授權表,即是可以跳過密碼驗證直接進入資料庫。
service mysqld restart //重啟mysql資料庫。假如不重啟的話,不會生效。
mysql -uroot -p //此時直接回車,既可以進入資料庫。
出現mysql就說明你已經進入到mysql資料庫里了。
進資料庫後,
use mysql //選擇mysql這個庫,因為mysql的root密碼存放在這個資料庫里。
show tables //查看下mysql庫里有哪些表,我們需要操作的用戶名密碼都在user表裡。
desc user //查看下user表有哪些欄位
更改root密碼。
update user set password=password(‘123456’) where user=”root”; //用戶選root,可以隨便更改成任意密碼,我這裡設置的123456,password()是mysql密碼加密的一個函數。
flush privileges; //刷新下密碼,使更改的生效。
exit //退出資料庫。
退出資料庫,重新登錄
mysql -uroot -p //回車輸入剛剛更改的密碼,就能進去了。
然後再次進入配置文件vi /etc/my.cnf 把skip-grant-tables去掉。
mysql給密碼欄位加密
你用hibernate的話,一般情況下也會用struts2的,你可以在action里寫一個MD5演算法,人,在調用,如
/**
* @MD5加密演算法
*/
public static String digestByMD5(String str) throws Exception {
// 採用MD5加密演算法,將任意長度字元串加密
MessageDigest md = MessageDigest.getInstance(“MD5”);
byte[] bts = md.digest(str.getBytes());
// 採用Base64演算法,將加密後的位元組變成字元串
BASE64Encoder encoder = new BASE64Encoder();
return encoder.encode(bts);
}
原創文章,作者:小藍,如若轉載,請註明出處:https://www.506064.com/zh-tw/n/291895.html