Remote database access

Your database isn't reachable from the internet - it only accepts connections from the server itself, over a local socket. To reach it from your computer or another server, you tunnel through SSH.

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.

Connect your database client

With the tunnel up, use these connection details in your database client (TablePlus, DBeaver, Sequel Ace, etc.):

  • Host: 127.0.0.1
  • Port: 3306 (or the local port you chose for the tunnel)
  • Database name, user, and password: found in your site's wp-config.php file (DB_NAME, DB_USER, and DB_PASSWORD), which you can view over SFTP.

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.