Skip to main content
Remote Database Access

How to connect to your database from your computer or another server

Karl avatar
Written by Karl
Updated over 7 months ago

To access a website's database remotely from your computer or another server, you must set up an SSH tunnel.

Set up an SSH tunnel

  1. Establish the tunnel:
    Use the following command to establish a tunnel between your computer and the Templ website:
    ​

    ssh -p PORT USER@IPADDRESS -L127.0.0.1:3306:/var/run/mysqld/mysqld.sock


    Replace PORT, USER, and IPADDRESS with the actual credentials found on the website's details page in the Templ Panel.
    ​

  2. Access the database:
    Once the SSH connection has been established, you can access the database on your computer on port 3306, or another port.
    ​

Note: If you already have a database set up that is using port 3306, you'll need to set up the SSH tunnel on a different port, such as port 3307.

When do I need to remotely access the database?

Remote database access can be useful when you want to:

  • Use desktop applications such as TablePlus, DBeaver, Sequel Ace, or Sequel Pro for database management.

  • Allow analytics or business applications such as Metabase to connect to and utilize the database for data analysis and visualization.
    ​

Did this answer your question?