How to Recover a Stored Password from HeidiSQL

Oct 2015

It happens to all of us. Maybe you trashed the sticky note you wrote the password on. Maybe someone on your dev team changed the database connection credentials and forgot to tell you. Maybe it's been a while since you last connected to the database, and now when you try to connect, for some unknown reason, it's not working. Whatever the case, there's nothing worse than firing up HeidiSQL, receiving a connection error and not being able to tell if the stored password is correct.

This has happened to me more times than I care to admit. In fact, that's why I'm writing this article. Recovering a stored password from HeidiSQL is relatively easy, though not necessarily an intuitive process. So here's how to recover a password stored in HeidiSQL in six simple steps.

  1. Open HeidiSQL and select File > Export Settings to dump settings into a text file.
    Export settings in HeidiSQL
  2. Open the text file and search on the host name of the database you want to recover the password for.
  3. A couple lines below the host name is the encoded password. It'll look something like: 755A5A585C3D8141. Keep this handy.
  4. Copy the following code into a new document.
    <!doctype html>
    function heidiDecode(hex) {
        var str = '';
        var shift = parseInt(hex.substr(-1));
        hex = hex.substr(0, hex.length - 1);
        for (var i = 0; i < hex.length; i += 2) 
            str += String.fromCharCode(parseInt(hex.substr(i, 2), 16) - shift); 
        return str; 
    document.write(heidiDecode('[ENCODED_PASSWORD]')); </script>
  5. Copy and paste the encoded password from the HeidiSQL settings file into the heidiDecode function as the value to be passed as the hex argument, i.e. replace [ENCODED_PASSWORD] with your actual encoded password.
  6. Save as a HTML document and run it in a web browser.

The text that displays on the web page is the decoded password stored in HeidiSQL. Simple!

Thanks to jpatters and his GitHub Gist, which I always eventually stumble upon after spending way too much time googling for a solution. Hopefully, this expanded explanation of that gist will help someone who's unfamiliar with exporting and reading HeidiSQL data dumps, working with JavaScript, or who needs help filling in the gaps in the gist's directions.

👋 Hi, I'm Chase
profile picture

I work at Verilogue, a medical marketing research company, as part of a rock star development team.

I enjoy writing about web design, and throughout this site share my experience as a front end developer working at the intersection of Big Data and Big Pharma.

In my spare time I like to compose music, which I link to from the playground along with all of my other side projects. I also spend a lot of time reading, mostly about web design and user experience with the occasional book on string theory or building time machines. Beyond that, I enjoy traveling, cooking, and playing World of Warcraft, where I main a Fire Mage named Wildford.

I grew up in Harrisburg, PA and graduated from Temple University in 2007 with a bachelor’s degree in Advertising and a minor in Sociology.

To learn more about me, check out my resume or let's talk on X.