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
- 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.
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.
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.phpfile (DB_NAME,DB_USER, andDB_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.