windows远程服务器数据库的搭建和远程访问(Mysql忘记密码通过Navicat连接记录解密密码)

发布于:2025-05-13 ⋅ 阅读:(10) ⋅ 点赞:(0)

服务器数据库的搭建和远程访问

mysql数据库安装(详细)

window安装mysql详细流程

安装完MySQL设置权限
(1)输入mysql -hlocalhost -u root -p
在这里插入图片描述
(2)输入 SELECT user, host FROM mysql.user;
在这里插入图片描述
(3)修改root用户有远程访问权限,输入

-- 修改root@localhost的host为%,使其可以远程访问
UPDATE mysql.user 
SET host = '%' 
WHERE user = 'root' AND host = 'localhost';

-- 刷新权限
FLUSH PRIVILEGES;

在这里插入图片描述
(4)解决版本报错(连接MySQL报错)
错误显示:2059 - Authentication plugin ‘caching_sha2_password’ cannot be loaded;
典型的MySQL数据库连接认证失败错误,主要原因是:
​​版本不兼容问题​​:您正在尝试使用较旧版本的MySQL客户端驱动连接到一个使用MySQL 8.0或更高版本的服务器
caching_sha2_password是MySQL 8.0引入的新认证插件,而旧版客户端驱动不支持这个插件
在这里插入图片描述
​修改用户认证方式ALTER USER '您的用户名'@'主机名' IDENTIFIED WITH mysql_native_password BY '您的密码';
在这里插入图片描述

路程重设MySQL5密码,发现远程服务器原本有一个MySQL5,尝试在服务器本地建立连接被拒绝,因为不知道密码。
(1)注意mysql服务名:否则会报错服务名无效。
在这里插入图片描述
(2)MySQL5输入指令跳过密码验证时报错

mysqld --skip-grant-tables

安装MySQL的时候报这个错误,由于找不到 VCRUNTIME140_1.dll,无法继续执行代码,重新安装程序可能会解决此问题。
解决:根据文章,下载安装Visual C++ 2015-2019 Redistributable,双击。在这里插入图片描述
(我看到有人将这个文件拷贝到mysql/bin 目录下,再次执行。怀疑是mysql目录下缺失这个文件导致的。我这样做了之后,远程服务器崩溃了黑屏了,哈哈哈哈哈,我真哈哈哈,被带去机房重启服务器了,然后被要求换了个服务器安装,那个远程服务器有正常的MySQL,可惜了,没法折腾了~~,好吧今日闯祸到此为止…未来可期)

续:
服务器mysql5连不上,应该是密码的问题,问题是不知道密码
(问题是配置文件ini修改了还是不能通过mysqld --skip-grant-tables指令跳过输入密码)

这个博主好厉害啊啊啊啊,通过Navicat连接过数据库,查历史记录来解密
https://www.cnblogs.com/BKYhailong/p/18080385

在线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";

网站公告

今日签到

点亮在社区的每一天
去签到