How to retrieve saved MySQL Workbench passwords

I use MySQL Workbench a fair bit with Azure hosted MySQL databases. and various other MySQL servers. To make life easier I often save the passwords for non sensitive systems to the MySQL Workbench password vault.

I recently hit a problem when moving to a new laptop, I realised I didn’t have the password for a connection I needed. The downside of relying on saved credentials!

In this short post I will give you steps to retrieve all the saved passwords stored in the vault, just using PowerShell on the source computer which holds the saved passwords.

Steps

Open PowerShell on the source computer, the one that holds the password vault, logged on with the user that has the connections saved.

Run the below PowerShell commands.

Add-Type -AssemblyName System.Security

$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)

Expected Result

You should get a list of all the saved connections, along with their associated usernames and passwords.

The output is one joined up string per connection, so you will need to work out where the username starts and ends.

Last tested on Windows 11 February 2024

Conclusion

In this short port I showed how if you still have access to the source computer you can with just a few PowerShell commands retrieve the credentials saved by MySQL Workbench

Leave a Comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.