October 12, 2023

How to connect to Magento Cloud Database using SSH

If you need access to the Magento Cloud Database to explore tables, run some SQL queries, etc., you can do so by opening an ssh tunnel using the magento-cloud utility so the step-by-step guide is below.

In this example I will use HeidiSQL - is free software, and has the aim to be easy to learn. "Heidi" lets you see and edit data and structures from computers running one of the database systems MariaDB, MySQL, Microsoft SQL, PostgreSQL and SQLite.

In the Magento folder, run the command

magento-cloud tunnel:single

Select needed database/application

Enter a number to choose a relationship:
  [0] database (database_stg)
  [1] database-slave (database_stg)
  [2] elasticsearch
  [3] redis
  [4] redis-slave

In this example, let it be 0 - the main database

SSH tunnel opened to database at: mysql://user:[email protected]:30000/database_stg?compression=1

Run HeidiSQL to establish a connection to the database

  1. Create new session
  2. Network type MariaDb or MySQL
  3. Host name
  4. Port: 30000
  5. User: your_user_name
  6. Password: ***** heidisql-connect-to-magento-cloud-db11-48-54.png


  1. Secure connections to remote environments
  2. HeidiSQL

Not sure which platform or technology to use?

We can turn different applications and technologies into a high-performance ecosystem that helps your business grow.