首先去检查你的加密文件在哪里。通常它存储在
%AppData%\MySQL\Workbench\workbench_user_data.dat
现在您有了文件位置,打开 powershell 并复制并粘贴以下命令序列(顺序很重要):
$cipher = Get-Content $env:APPDATA\MySQL\Workbench\workbench_user_data.dat -Encoding Byte
回车
$scope = [System.Security.Cryptography.DataProtectionScope]::CurrentUser
回车
$mysqlpwd = [System.Security.Cryptography.ProtectedData]::Unprotect(
$cipher, $null, $scope )
回车
[System.Text.UTF8Encoding]::UTF8.GetString($mysqlpwd)
回车
现在可以看到如下输出:
Mysql@X:Y@Z#DBUSER#DBPASSWORD
...
ssh@Z:22#SSHUSER#SSHPASSWORD
...
如果您收到 TypeNotFound 错误:
无法找到类型 [System.Security...]。
您可能还需要运行以下命令才能访问“System.Security”
Add-Type -AssemblyName System.Security
参考资料:
无法在Windows 上的MySQL Workbench 中查看存储的密码。该实现使用 Windows 加密 API 并将加密的密码存储在自己的文件中,该文件只能由同一主机上的同一用户解密,从中加密。
从该保险库中获取密码的唯一解决方案是使用 Workbench 正在使用的代码。这就需要为此任务编写一个小工具。