Pivotal Knowledge Base

Follow

Cannot Connect to a MySQL Service Instance from an External MySQL Management Tool

Environment

Pivotal Web Services (PWS)

MySQL for Pivotal Cloud Foundry

Symptom

When attempting to connect to a PWS MySQL instance via an external MySQL management tool you will receive the error.

Error Message:

Can't connect to MySQL server on 'p-mysql-proxy.run.pivotal.io' (10060)

Cause

There is no direct access to them from the cloud because they are shielded externally by AWS networking rules. The PWS MySQL DB instances are not externally visible and are only accessible by your apps.

Resolution

A workaround to this is to use SSH Tunneling and the MySQL CLI.

Configure an SSH tunnel to your service instance using cf ssh. Tailor the example command below with information from your service key.

$ cf ssh -L 63306:us-cdbr-iron-east-01.p-mysql.net:3306 YOUR-HOST-APP
  1. Use any available local port for port forwarding. For example, 63306.
  2. Replace us-cdbr-iron-east-01.p-mysql.net with the address provided under hostnamein the service key retrieved above.
  3. Replace 3306 with the port provided under port above.
  4. Replace YOUR-HOST-APP with the name of your host app.

After you enter the command, open another terminal window and perform the steps below.

To establish direct command-line access to your service instance, use the relevant command line tool for that service. This example uses the MySQL command line client to access the p-mysql service instance.

$ mysql -u b5136e448be920 -h 0 -p -D ad_b2fca6t49704585d -P 63306
  1. Replace b5136e448be920 with the username provided under username in your service key.
  2. -h 0 instructs mysql to connect to your local machine.
  3. -p instructs mysql to prompt for a password. When prompted, use the password provided under password in your service key.
  4. Replace ad_b2fca6t49704585d with the database name provided under name in your service key.
  5. -P 63306 instructs mysql to connect on port 63306.

Alternatively, deploying a tool on PWS such as phpMyAdmin is also an option. You can find an example of a CF ready version hereYou must change the local port to 63306.

Additional Information

Reference: https://docs.pivotal.io/pivotalcf/2-0/devguide/deploy-apps/ssh-services.html

Comments

Powered by Zendesk