如何解決Navicat已經(jīng)成功連接,密碼忘記的問題
一直想寫一下這篇文章的總結(jié),因為有時真的忘記了,要去網(wǎng)上重新搜索一下之前用過的方法,因此這里記錄一下,也為了以后遇到這種問題可以直接看我的文章,而不是到處找,以下為實踐篇。
1. 如果是win,通過注冊表里去找對應(yīng)的數(shù)據(jù),用php解碼
去cmd里輸入
regedit
去到對應(yīng)的注冊表

查找Navicat的密碼保存位置
去到對應(yīng)的路徑下面
計算機\HKEY_CURRENT_USER\Software\PremiumSoft
可以看到

打開對應(yīng)的目錄,尋找一下servers下要找的數(shù)據(jù)庫,如我要找阿里云的密碼

尋找pwd找出來,復(fù)制數(shù)據(jù)

去到
https://tool.lu/coderunner/
復(fù)制黏貼一下php解密的代碼
<?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";
將15057D7BA390復(fù)制到倒數(shù)第二行
點擊執(zhí)行,得到密碼

2. linux/win/蘋果桌面情況下,可導(dǎo)出連接看然后去php解密(適用)


導(dǎo)出后用notepad++看里面的代碼
尋找password值

復(fù)制888B51B60B5FF32FAF86AC去第一種方法php方法里解密

3. 直接登錄navicat,用命令去改密碼
通過Navicat Premium能登陸MySQL,但root用戶密碼忘記了
方法: 用UPDATE直接編輯user表
mysql -u root
mysql> use mysql;
mysql> UPDATE user SET Password = PASSWORD('newpass') WHERE user = 'root'; mysql> FLUSH PRIVILEGES;
總結(jié)
- 從操作上沒有卡手的地方
- 不太明白為什么說php是最好的語言,猜測用java寫出來也是可以解密的
以上為個人經(jīng)驗,希望能給大家一個參考,也希望大家多多支持腳本之家。
相關(guān)文章
KingbaseES數(shù)據(jù)類型從基礎(chǔ)CHAR到JSON/XML/幾何類型完全指南
在數(shù)據(jù)類型體系方面,KingbaseES展現(xiàn)出極強的完備性與專業(yè)性,這篇文章主要介紹了KingbaseES數(shù)據(jù)類型從基礎(chǔ)CHAR到JSON/XML/幾何類型的相關(guān)資料,文中通過代碼介紹的非常詳細(xì),需要的朋友可以參考下2026-05-05
數(shù)據(jù)庫的設(shè)計方法、規(guī)范與技巧
數(shù)據(jù)庫的設(shè)計方法、規(guī)范與技巧...2007-03-03
一次數(shù)據(jù)庫查詢超時優(yōu)化問題的實戰(zhàn)記錄
當(dāng)MySQL服務(wù)器出現(xiàn)異常(慢),首先要考慮是否因SQL語句引起數(shù)據(jù)庫慢,下面這篇文章主要給大家介紹了一次數(shù)據(jù)庫查詢超時優(yōu)化問題的實戰(zhàn)記錄,需要的朋友可以參考下2021-10-10
數(shù)據(jù)庫 SQL千萬級數(shù)據(jù)規(guī)模處理概要
我在前年遇到過過億條的數(shù)據(jù)。以至于一個處理過程要幾個小時的。后面慢慢優(yōu)化,查找一些經(jīng)驗文章。才學(xué)到了一些基本方法。綜合敘之,與君探討之。2009-07-07
JetBrains出品一款好用到爆的DataGrip數(shù)據(jù)庫工具使用入門
這篇文章主要介紹了JetBrains出品一款好用到爆的DataGrip數(shù)據(jù)庫工具使用入門,本文給大家介紹的非常詳細(xì),對大家的學(xué)習(xí)或工作具有一定的參考借鑒價值,需要的朋友可以參考下2021-01-01
navicat導(dǎo)入excel文件的步驟以及可能碰到的問題
本文介紹將excel導(dǎo)入到mysql數(shù)據(jù)庫的方法,相對來說比較簡單,但也可能會碰到一些小問題,在這里做一個小的總結(jié),這里使用到的工具包括navicat,mysql數(shù)據(jù)庫以及excel,需要的朋友可以參考下2024-07-07

