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
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.
β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.
β