To use a local MySQL manager or other application to connect to a database on Stratus, an SSH tunnel is preferred. SSH tunnels are possible with a variety of clients. Putty and OpenSSH are used in the following examples.
Before you can connect, you need several pieces of information:
- A working SSH login to your Stratus instance.
- The IP address that will to the Stratus MySQL (i.e., the same IP allowed for SSH access)
- Your database credentials. In your Stratus managment panel, expand the MySQL section and click Info to see your database username and password
If you have the above, you can proceed.
Creating a Tunnel with PuTTY
- Open PuTTy on your computer.
- Enter the SSH Host address shown SSH > Info.
- From the left-hand tree in PuTTY, go to Connection > SSH > Tunnels.
- Source Port — Enter "3306". If MySQL is locally using this port, enter another port number (e.g. "3307").
- Destination — Enter the Stratus hostname combined with the host port of "3306" (e.g. "ssh.5uiwe1x3ngdgg75c.mojostratus.io:3306")
- Click Add.
- Click Open. Accept the SSH if requested.
- Log in with the Stratus SSH User credentials.
The SSH tunnel to the remote database is now open. Connect locally using a MySQL client application. Use an IP of 127.0.0.1 and port number of 3306.
Creating a Tunnel with OpenSSH
A secure tunnel to the Stratus database can be created using one command line:
ssh -p <SSHport> -L <localport>:mysql:3306 <SSHuser>@<SSHhost>
- SSHport — Use the SSH Port found in your SSH Info panel.
- localport — Normally "3306", the local port used to access MySQL. If an instance of MySQL is already running locally, an alternative port may be used, such as "3307".
- SSHuser — Stratus SSH Username.
- SSHhost — Found in the Stratus SSH Info panel.
Using this format, a typical OpenSSH tunnel might be created using:
ssh -p 21937 -L 3306:mysql:3306 firstname.lastname@example.org
After entering this into the terminal window, enter the Stratus SSH user password.
While this tunnel connection is open, open a new terminal window and connect to the Stratus MySQL database as if it were local.