Try PCF on your Local Workstation with PCF Dev

A tutorial for learning Pivotal Cloud Foundry app development concepts with PCF Dev

Connect a Database

If a database isn't available, the sample app uses a temporary in-memory database. This app supports MySQL, Postgres, Redis, and MongoDB.

You can see what type of database this app is using by clicking the info icon in the upper right corner of your app.

view sample app info

Let's configure this app to use a MySQL database.

List what plans are available:

cf marketplace -s p-mysql

Create a service instance with the 512mb plan:

cf create-service p-mysql 512mb my-spring-db

Bind the newly created service to the app:

cf bind-service spring-music my-spring-db

Once a service is bound to an app, environment variables are stored that allow the app to connect to the service after a push, restage, or restart command.

Restart the app:

cf restart spring-music

Now verify the new service is bound to your app. You can do this on the command line, or by clicking on the info icon in the upper right corner of the sample app.

Verify the new service is bound to the app:

cf services
Getting services in org your-org / space development ...
name             service   plan    bound apps
spring-music-db  p-mysql   512mb   spring-music