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

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

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



4.使用 https://tool.lu/coderunner/ 在線工具,對(duì)復(fù)制下來(lái)的密碼15057D7BA390進(jìn)行解密
5.將以下php解密代碼復(fù)制到在線工具中,將復(fù)制的數(shù)據(jù)粘貼到代碼的倒數(shù)第二行,點(diǎn)擊執(zhí)行,即可得到密碼
PS:該工具首行不能空行,否則執(zhí)行會(huì)報(bào)錯(cuò);另外,在代碼倒數(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";
二:通過(guò)Navicat導(dǎo)出連接,找到連接密碼,再通過(guò)PHP進(jìn)行解密
具體操作:
1.打開(kāi)Navicat,導(dǎo)航欄點(diǎn)擊“文件”,點(diǎn)擊“導(dǎo)出連接”,

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

3.打開(kāi)導(dǎo)出的文件,找到Password這一項(xiàng),將引號(hào)中的數(shù)據(jù)復(fù)制下來(lái)

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

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

