LATEST VERSION: 2.2 - CHANGELOG

Customizing Database Credentials

This topic provides instructions for developers to customize access credentials and privileges for MySQL for Pivotal Cloud Foundry (PCF) service instances.

These procedures use the Cloud Foundry Command Line Interface (cf CLI). You can also use Apps Manager to do the same tasks using a graphical UI.

For information about using MySQL for PCF, see Using MySQL for PCF.

Create Read-only Access Credentials

MySQL for PCF lets space developers create read-only credentials to give to users who need read-only access to the database. You can create credentials by using the cf CLI to create a new service key.

To create and find read-only credentials for an existing service instance, do the following:

  1. Run the following command to create a new service key for a service instance, specifying it to be read-only:

    cf create-service-key SERVICE-INSTANCE KEY-NAME -c '{ "read-only": true }'

    Where:

    SERVICE-INSTANCE: The name of the service instance

    KEY-NAME: What you want to call the key

    For example,

    $ cf create-service-key mydb mykey1 -c '{ "read-only": true }'
    Creating service key mykey1 for service instance mydb as admin...
    OK
  2. Run the following command to retrieve the read-only credentials from the service key:

    cf service-key SERVICE-INSTANCE KEY-NAME

    For example,

    $ cf service-key mydb mykey1
    { "hostname": "99.99.99.9", "jdbcUrl": "jdbc:mysql://99.99.99.9:3306/cf_e2d148a8_1baa_4961_b314_2431f57037e5?user=abcdefghijklm\u0026password=123456789", "name": "cf_e2d148a8_1baa_4961_b314_2431f57037e5", "password": "123456789", "port": 3306, "uri": "mysql://abcdefghijklm:123456789@99.99.99.9:3306/cf_e2d148a8_1baa_4961_b314_2431f57037e5?reconnect=true", "username": "abcdefghijklm" }

Note: Any user with access to create a service key may provision a fully privileged service key.

Create Credentials for a Custom Username

If you have users that want to access the database with a specific username, MySQL for PCF lets space developers create custom usernames for service keys or service bindings. You can create credentials by using the cf CLI to create a new service key.

To create and find custom username credentials for an existing service instance, do the following:

  1. Create a new service key for a service-instance, specifying a username:

    $ cf create-service-key SERVICE-INSTANCE KEY-NAME -c '{ "username": NEW-USER-NAME }'

    For example,

    $ cf create-service-key mydb mykey2  -c '{ "username": myuser }'
    Creating service key mykey2 for service instance mydb as admin...
    OK

  2. Run the following command to retrieve the credentials from the service key.

    cf service-key SERVICE-INSTANCE KEY-NAME

    For example,

    $ cf service-key mydb mykey2
    { "hostname": "10.10.10.5", "jdbcUrl": "jdbc:mysql://10.10.10.5:3306/cf_e2d148a8_1baa_4961_b314_2431f57037e5?user=my_unique_name\u0026password=123456789", "name": "cf_e2d148a8_1baa_4961_b314_2431f57037e5", "password": "123456789", "port": 3306, "uri": "mysql://my_unique_name:123456789@10.10.10.5:3306/cf_e2d148a8_1baa_4961_b314_2431f57037e5?reconnect=true", "username": "myuser" }

Note: Any user with access to create a service key may provision a fully privileged service key.

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