This question is essentially the same question as this one, but for Windows 10.

I have checked the documentation and still have no clear answer. A step by step for viewing the password would be perfect and truly appreciated!
First go check where your encrypted file is. Usually it is stored at %AppData%\MySQL\Workbench\workbench_user_data.dat
Now that you have the file location, open up powershell and copy & paste the following sequence of commands (order is important):
$cipher = Get-Content $env:APPDATA\MySQL\Workbench\workbench_user_data.dat -AsByteStream -Raw
Hit Enter
$scope = [System.Security.Cryptography.DataProtectionScope]::CurrentUser
Hit Enter
$mysqlpwd = [System.Security.Cryptography.ProtectedData]::Unprotect(
$cipher, $null, $scope )
Hit Enter
[System.Text.UTF8Encoding]::UTF8.GetString($mysqlpwd)
Hit Enter
Now you can see the following output:
Mysql@X:Y@Z#DBUSER#DBPASSWORD
...
ssh@Z:22#SSHUSER#SSHPASSWORD
...
If you receive a TypeNotFound error:
Unable to find type [System.Security...].
you may also need to run the following to get access to "System.Security"
Add-Type -AssemblyName System.Security
References:
I made a quick Python solution adapted from the link in Mike's answer, since the PowerShell answer didn't work for me.
import os
import re
import win32crypt # Requires pywin32 package
_group = '(?P<{}>{}+)'
WORKBENCH_PATTERN = '{dbm}@{host}:{port}\2{user}\3{password}'.format(
dbm=_group.format('dbm', r'\w'),
host=_group.format('host', r'[\w\.-]'),
port=_group.format('port', r'\d'),
user=_group.format('user', r'[\w\.-]'),
password=_group.format('password', '.'),
)
def read_workbench_user_data(file_path=None):
if file_path is None:
file_path = os.path.join(os.getenv('APPDATA'), 'MySQL/Workbench/workbench_user_data.dat')
with open(file_path, 'rb') as file:
encrypted_data = file.read()
decrypted_data = win32crypt.CryptUnprotectData(encrypted_data, None, None, None, 0)
decrypted_content = decrypted_data[1].decode('utf-8')
return decrypted_content.split('\n')[:-1]
if __name__ == '__main__':
for item in read_workbench_user_data():
match = re.match(WORKBENCH_PATTERN, item)
print(f'{match.group("dbm")}:')
print(f'\tHost: {match.group("host")}:{match.group("port")}')
print(f'\tUsername: {match.group("user")}')
print(f'\tPassword: {match.group("password")}')
Here's how the output looks:

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With