If you’re familiar with Rackspace Cloud Databases, you are probably aware that you cannot directly connect to your database remotely (outside of the Rackspace internal network).
You can, however, use an SSH Tunnel to access your database remotely through a rackspace cloud server instance. Here’s how.
Prerequisites
- You must have a Rackspace Cloud Server Instance with SSH Access
- You must have a Rackspace Cloud Database Instance, with a Database, User & Password assigned to it.
Step 1: Connect to Cloud Server from PC
First, we must connect to our Cloud Server using SSH to store the server host key locally. To do this, do the following:
- Download plink.exe and save it to your C:\ drive.
- Open up Command Prompt, and do the following commands:
Replace [CLOUD SERVER IP ADDRESS] with the IP address of your cloud server.
cd C:\ plink.exe -L 3307:[CLOUD SERVER IP ADDRESS]:3306 root@[CLOUD SERVER IP ADDRESS]
- After completing the above commands, you will most likely see a message saying “The server’s host key is not cached….”
Entery
when it asks Store key in cache? - When prompted for a password, Enter your Cloud Server root user password.
- You should now be connected to your cloud server using an SSH connection.
Step 2: Connect Using MySQL Management Software
Now we should be able to connect using a MySQL management tool such as HeidiSQL, which is a completely free solution that offers SSH Tunneling.
- Download & Install HeidiSQL
- Open HeidiSQL and go to the Session Manager.
- Create a New Session clicking the New button
- On the Settings tab, enter the following:
Network Type: SSH Tunnel
Hostname/IP:[HOSTNAME OF CLOUD DATABASE INSTANCE]
User:[CLOUD DATABASE USERNAME]
Password:[CLOUD DATABASE PASSWORD]
Port:3307
Uncheck Compressed client/server protocol
Databases: [CLOUD DATABASE NAME(S)] – comma separated if more than one database. - On the SSH Tunnel tab, enter the following:
plink.exe location: Download plink.exe, and point this to it’s location
SSH Host + port:[CLOUD SERVER HOSTNAME or IP]
Username:[CLOUD SERVER SSH USERNAME]
Password:[CLOUD SERVER SSH PASSWORD]
Private Key File: Not needed, leave blank.
Local Port: 3307 - Click the Open button at the bottom. You should now be connected to your cloud database.
Hi
A quick point here – when using Rackspace’s servers to host your MySQL DB – you should use the private network to connect to your web servers and then you need to use this Plink method to connect via SSH to use Heidi SQL. If you do this then the settings need to be as follows:
On the Settings tab, enter the following:
Network Type: SSH Tunnel
Hostname/IP: IP Address of your internal network card (this is what MySQL should be bound to in my.cnf)
User: [CLOUD DATABASE USERNAME]
Password: [CLOUD DATABASE PASSWORD]
Port: 3306
On the SSH Tunnel tab, enter the following:
plink.exe location: Download plink.exe, and point this to it’s location
SSH Host + port: [CLOUD SERVER HOSTNAME or IP] Port 22
Username: [CLOUD SERVER SSH USERNAME]
Password: [CLOUD SERVER SSH PASSWORD]
Private Key File: Not needed, leave blank.
Local Port: 3307
Best regards
Phil