解決Navicat數(shù)據(jù)庫連接成功但密碼忘記的問題
解決方法
一:通過注冊表找到數(shù)據(jù)庫連接的密碼,再通過PHP解密
具體操作:
1.用 win + R 快捷鍵打開運行窗口,輸入 regedit 打開注冊表

2.在注冊表地址欄輸入下面內(nèi)容,查找Navicat密碼保存位置,回車:
計算機\HKEY_CURRENT_USER\SOFTWARE\PremiumSoft\Navicat\Servers

3.在servers目錄下,找到需要找回密碼的連接,鼠標(biāo)左鍵點擊,右側(cè)下拉找到名稱為 pwd 的一項,該項的數(shù)據(jù)即為密碼。右鍵,點擊修改,復(fù)制數(shù)據(jù):



4.使用 https://tool.lu/coderunner/ 在線工具,對復(fù)制下來的密碼15057D7BA390進行解密
5.將以下php解密代碼復(fù)制到在線工具中,將復(fù)制的數(shù)據(jù)粘貼到代碼的倒數(shù)第二行,點擊執(zhí)行,即可得到密碼
PS:該工具首行不能空行,否則執(zhí)行會報錯;另外,在代碼倒數(shù)五六行需要指定Navicat版本
<?php
namespace FatSmallTools;
class NavicatPassword
{
protected $version = 0;
protected $aesKey = 'libcckeylibcckey';
protected $aesIv = 'libcciv libcciv ';
protected $blowString = '3DC5CA39';
protected $blowKey = null;
protected $blowIv = null;
public function __construct($version = 12)
{
$this->version = $version;
$this->blowKey = sha1('3DC5CA39', true);
$this->blowIv = hex2bin('d9c7c3c8870d64bd');
}
public function encrypt($string)
{
$result = FALSE;
switch ($this->version) {
case 11:
$result = $this->encryptEleven($string);
break;
case 12:
$result = $this->encryptTwelve($string);
break;
default:
break;
}
return $result;
}
protected function encryptEleven($string)
{
$round = intval(floor(strlen($string) / 8));
$leftLength = strlen($string) % 8;
$result = '';
$currentVector = $this->blowIv;
for ($i = 0; $i < $round; $i++) {
$temp = $this->encryptBlock($this->xorBytes(substr($string, 8 * $i, 8), $currentVector));
$currentVector = $this->xorBytes($currentVector, $temp);
$result .= $temp;
}
if ($leftLength) {
$currentVector = $this->encryptBlock($currentVector);
$result .= $this->xorBytes(substr($string, 8 * $i, $leftLength), $currentVector);
}
return strtoupper(bin2hex($result));
}
protected function encryptBlock($block)
{
return openssl_encrypt($block, 'BF-ECB', $this->blowKey, OPENSSL_RAW_DATA|OPENSSL_NO_PADDING);
}
protected function decryptBlock($block)
{
return openssl_decrypt($block, 'BF-ECB', $this->blowKey, OPENSSL_RAW_DATA|OPENSSL_NO_PADDING);
}
protected function xorBytes($str1, $str2)
{
$result = '';
for ($i = 0; $i < strlen($str1); $i++) {
$result .= chr(ord($str1[$i]) ^ ord($str2[$i]));
}
return $result;
}
protected function encryptTwelve($string)
{
$result = openssl_encrypt($string, 'AES-128-CBC', $this->aesKey, OPENSSL_RAW_DATA, $this->aesIv);
return strtoupper(bin2hex($result));
}
public function decrypt($string)
{
$result = FALSE;
switch ($this->version) {
case 11:
$result = $this->decryptEleven($string);
break;
case 12:
$result = $this->decryptTwelve($string);
break;
default:
break;
}
return $result;
}
protected function decryptEleven($upperString)
{
$string = hex2bin(strtolower($upperString));
$round = intval(floor(strlen($string) / 8));
$leftLength = strlen($string) % 8;
$result = '';
$currentVector = $this->blowIv;
for ($i = 0; $i < $round; $i++) {
$encryptedBlock = substr($string, 8 * $i, 8);
$temp = $this->xorBytes($this->decryptBlock($encryptedBlock), $currentVector);
$currentVector = $this->xorBytes($currentVector, $encryptedBlock);
$result .= $temp;
}
if ($leftLength) {
$currentVector = $this->encryptBlock($currentVector);
$result .= $this->xorBytes(substr($string, 8 * $i, $leftLength), $currentVector);
}
return $result;
}
protected function decryptTwelve($upperString)
{
$string = hex2bin(strtolower($upperString));
return openssl_decrypt($string, 'AES-128-CBC', $this->aesKey, OPENSSL_RAW_DATA, $this->aesIv);
}
}
use FatSmallTools\NavicatPassword;
//需要指定版本,11或12
//$navicatPassword = new NavicatPassword(12);
$navicatPassword = new NavicatPassword(11);
//解密
$decode = $navicatPassword->decrypt('15057D7BA390');
echo $decode."\n";
二:通過Navicat導(dǎo)出連接,找到連接密碼,再通過PHP進行解密
具體操作:
1.打開Navicat,導(dǎo)航欄點擊“文件”,點擊“導(dǎo)出連接”,

2.選擇自己需要找回密碼的連接,并勾選左下角“導(dǎo)出密碼”,點擊“確定”

3.打開導(dǎo)出的文件,找到Password這一項,將引號中的數(shù)據(jù)復(fù)制下來

4.打開并使用方法一步驟4.中的在線工具和代碼,修改倒數(shù)第二行的內(nèi)容為步驟三保存的數(shù)據(jù)833E4ABBC56C89041A9070F043641E3B,點擊運行
PS:由于我使用的是Navicat 12,在這種方法中需要修改代碼中倒數(shù)第五六行的版本,否則解析出來亂碼

以上就是解決Navicat數(shù)據(jù)庫連接成功但密碼忘記的問題的詳細內(nèi)容,更多關(guān)于Navicat數(shù)據(jù)庫密碼忘記的資料請關(guān)注腳本之家其它相關(guān)文章!
相關(guān)文章
數(shù)據(jù)庫分頁查詢語句數(shù)據(jù)庫查詢
關(guān)于分頁 SQL 的資料許多,有的使用存儲過程,有的使用游標(biāo)。本人不喜歡使用游標(biāo),我覺得它耗資、效率低;使用存儲過程是個不錯的選擇,因為存儲過程是顛末預(yù)編譯的,執(zhí)行效率高,也更靈活2014-08-08
使用dump transaction with no_log的危險性說明
在命令參考手冊中的dump transaction with no_log條目下,有一條警告信息告訴你,你應(yīng)該把這條命令作為沒有其它辦法時的最后一招才使用它2012-07-07
Navicat恢復(fù)數(shù)據(jù)庫連接及查詢sql的完美解決辦法
因為公司給電腦加域,導(dǎo)致使用新的用戶賬戶,原先的很多配置都失效了,這篇文章主要介紹了Navicat恢復(fù)數(shù)據(jù)庫連接及查詢sql的解決辦法,需要的朋友可以參考下2023-08-08
Navicat premium連接數(shù)據(jù)庫出現(xiàn):2003 Can''t connect to MySQL server o
這篇文章主要介紹了Navicat premium連接數(shù)據(jù)庫出現(xiàn):2003 - Can't connect to MySQL server on 'localhost' (10061 "Unknown error")的問題,本文給大家介紹的非常詳細,對大家的學(xué)習(xí)或工作具有一定的參考借鑒價值,需要的朋友可以參考下2020-11-11

