It's not complicated to connect to a platform.sh database; here's how!

# Requirements

  • A database management application. I will use Sequel Pro in this post.
  • Set up a site on platform.sh.
    • Add your ssh-key to your account settings.

# Instructions

Open up Sequel Pro and click the + in the bottom left corner to create a new connection. You will be prompted for connection settings. At the top there are three tabs. Each type of connection prompts for different settings. Select the ssh tab for a platform.sh connection.

Sequel Pro Connection Screen

Let's break down the rest of the settings.

  • Name:
    • This can be anything that describes the database you are connecting to. I usually stick to the format: Example Site - Test.
  • MySQL Host:
    • This will literally be the string database.internal
  • Username:
    • Literally user
  • Password:
    • leave empty
  • Database:
    • Literally main
  • Port:
    • leave empty

The rest of the settings can easily be obtained through the ssh connection string provided by platform. To get the string, login to platform.sh, choose your project, hover over the Access site link, and copy the SSH ACCESS string to your clipboard.

  • SSH Host:
    • The part of the string after the @ ssh.us.platform.sh
  • SSH User:
    • This is the part of the string before the @ it consists of the platform site ID and the environment.
  • Leave the rest of the settings blank but make sure the Connect using SSL box is checked.

Sequel Pro should pick up your public key from your computer but if it can't you can browse to your public key to explicitly point to it (usually in ~/.ssh/).

That's it! Click Test Connection if it connects hit Save changes then Connect.

# Conclusion

You now have a new favorite in your Sequel Pro sidebar that you can use to connect to your Platform.sh environment anytime you need it.