LATEST VERSION: 2.1 - CHANGELOG

MySQL Environment Variables

This topic provides a reference for the environment variables that Cloud Foundry stores for MySQL for PCF service instances. These variables include the credentials that apps use to access the service instances.

VCAP_SERVICES

Applications running in Cloud Foundry gain access to the bound service instances via an environment variable credentials hash called VCAP_SERVICES. An example hash is show below:


{
  "p.mysql": [{
    "label": "p.mysql",
    "name": "my-instance",
    "plan": "db-medium",
    "provider": null,
    "syslog_drain_url": null,
    "tags": [
     "mysql"
    ],
    "credentials": {
      "hostname": "10.0.0.20",
      "jdbcUrl": "jdbc:mysql://10.0.0.20:3306/service_instance_db?user=fefcbe8360854a18a7994b870e7b0bf5\u0026password=z9z6eskdbs1rhtxt",
      "name": "service_instance_db",
      "password": "z9z6eskdbs1rhtxt",
      "port": 3306,
      "uri": "mysql://fefcbe8360854a18a7994b870e7b0bf5:z9z6eskdbs1rhtxt@10.0.0.20:3306/service_instance_db?reconnect=true",
      "username": "fefcbe8360854a18a7994b870e7b0bf5"
    },
    "volume_mounts": []
   }
}

You can search for your service by its name, given when creating the service instance, or dynamically via the tags or label properties. The credentials property can be used as follows:

  • The credentials properties uri, name, hostname, port, username, password, and jdbcUrl provide access to the MySQL protocol.

In common with all services in Pivotal Cloud Foundry (PCF), the VCAP_SERVICES environment variable for an application is only modified when the application is bound to a service instance. Users will need to cf unbind-service, cf bind-service and cf restage their app in this scenario.

Create a pull request or raise an issue on the source for this page in GitHub