Table of contents

Introduction

Have you ever found yourself in a bit of a bind after losing your database password within a JetBrains IDE on your Mac? It's a common hiccup for developers—after all, who hasn't misplaced a password or two in their career? But worry not; there’s a straightforward method to recover your database credentials on MacOSX. In this quick guide, we’ll show you how to retrieve your lost password from any JetBrains IDE, so you can get back to coding in no time. Let’s dive in and unlock your database!

Recovering your password

First, open your JetBrains IDE, GoLand in my case.

jetbrains ide database tab

Decide which database you need the password for, let's assume I lost password to the Preview DB.

Second, open a new Terminal window.

In the root directory of your project run: cat .idea/dataSources.xml

The file should look similar to this format:

<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
  <component name="DataSourceManagerImpl" format="xml" multifile-model="true">
    <data-source source="LOCAL" name="Preview" uuid="b4909956-00f1-431c-ab26-e40dccdab8bf">
      <driver-ref>postgresql</driver-ref>
      <synchronize>true</synchronize>
      <jdbc-driver>org.postgresql.Driver</jdbc-driver>
      <jdbc-url>jdbc:postgresql://localhost:2226/platform</jdbc-url>
      <working-dir>$ProjectFileDir$</working-dir>
    </data-source>
    <data-source source="LOCAL" name="Docker local" uuid="8efb1bef-0618-4f60-9229-1ac46b87e928">
      <driver-ref>postgresql</driver-ref>
      <synchronize>true</synchronize>
      <jdbc-driver>org.postgresql.Driver</jdbc-driver>
      <jdbc-url>jdbc:postgresql://localhost:5432/</jdbc-url>
      <working-dir>$ProjectFileDir$</working-dir>
    </data-source>
    <data-source source="LOCAL" name="QA" uuid="8a332937-93c9-4310-a1ab-64192c815253">
      <driver-ref>postgresql</driver-ref>
      <synchronize>true</synchronize>
      <jdbc-driver>org.postgresql.Driver</jdbc-driver>
      <jdbc-url>jdbc:postgresql://localhost:54321/platform?sslmode=disable</jdbc-url>
      <working-dir>$ProjectFileDir$</working-dir>
    </data-source>
  </component>
</project>%                               

As you can see data-source Preview has UUID of b4909956-00f1-431c-ab26-e40dccdab8bf

Thirdly and lastly, open your Keychain Access on Mac.

osx keychain goland database password recovery

Paste in your data source UUID in the search bar, and voila! From there you can simply copy the password to clipboard.

And that's it.. I hope this tutorial has helped you.