Pivotal Knowledge Base


How to Migrate Spring Cloud Services Broker Database from MySQL v1 to v2


Spring Cloud Services v1.5 and above


Spring Cloud Services v1.5 supports MySQL For PCF v2, which creates dedicated, single-tenant service instances dynamically. This article describes the migration of Spring Cloud Services database from MySQL v1 instance to v2 instance. 



  • MySQL v2 has been installed.
  • mysqldump and MySQL utility


  1. Target Spring Cloud Services broker space
    $ cf t -o system -s p-spring-cloud-services
  2. Stop broker
    $ cf stop spring-cloud-broker 
  3. Obtain broker database credentials
    $ cf env spring-cloud-broker 
    System-Provided > VCAP_SERVICES > p-mysql > credentials > uri
    "jdbcUrl": "jdbc:mysql://<mysql_server>:3306/<database_name>?user=<user>\u0026password=<password>"
  4. Dump broker database
    $ mysqldump -h <MYSQL_SERVER> -P 3306 -u <USER> -p<PASSWORD> --databases <DATABSE_NAME> > scs_broker_backup.sql
  5. Rename broker database
    $ cf unbind-service spring-cloud-broker spring-cloud-broker_db
    $ cf rename-service spring-cloud-broker-db spring-cloud-broker-db-mysqlv1
  6. Create MySQL v2 database instance, plan name must be an existing plan.
    $ cf create-service p.mysql db-small spring-cloud-broker-db
  7. Confirm new database instance "create succeeded", then bind to broker
    $ cf service spring-cloud-broker-db
    $ cf bind-service spring-cloud-broker spring-cloud-broker-db
  8. Locate new database access credentials as step #3.
  9. Edit 'scs_broker_backup.sql', look for the line 'CREATE DATABASE', 'USE' and comment, then replace the old database name with the 'service_instance_db' name found in the previous step. Please refer the example as below which has updated database name.
    -- MySQL dump 10.13  Distrib 5.7.20, for osx10.13 (x86_64)
    -- Host:    Database: service_instance_db
    -- ------------------------------------------------------
    -- Server version	5.5.5-10.1.26-MariaDB
    /*!40101 SET NAMES utf8 */;
    /*!40103 SET @OLD_TIME_ZONE=@@TIME_ZONE */;
    /*!40103 SET TIME_ZONE='+00:00' */;
    /*!40111 SET @OLD_SQL_NOTES=@@SQL_NOTES, SQL_NOTES=0 */;
    -- Current Database: `service_instance_db`
    CREATE DATABASE /*!32312 IF NOT EXISTS*/ `service_instance_db` /*!40100 DEFAULT CHARACTER SET utf8 COLLATE utf8_unicode_ci */;
    USE `service_instance_db`;
  10. Import dumped data back to the newly created database.
    $ mysql -h MYSQL_SERVER -P 3306 -u USER -p<PASSWORD> MYSQL_SERVER < scs_broker_backup.sql
  11. Start broker
    $ cf start spring-cloud-broker
  12. Confirm service instances are correctly listed at https://spring-cloud-broker.<PCF_APP_DOMAIN>.
  13. Configure Ops Manager from Spring Cloud Services by going to Spring Cloud Services, 
    • Persistence store service => p.mysql
    • Persistence store service plan =>the same MySQL v2 service plan name that was used in step #6
  14. Turn Post-Deploy errands to "When Changed". 
  15. Click Apply Change.
  16. Once the deployment and smoke-tests complete successfully, delete MySQL v1 instance. 
    $ cf delete-service spring-cloud-broker-db-mysqlv1


  • There is downtime during migration with Spring Cloud Services broker, the developer cannot create, delete, bind, or unbind Spring Cloud Services instances.
  • No downtime is there with running Spring Cloud Services instances. 

Additional Information

In case of no direct access to the MySQL servers, ssh tunnel must be configured for accessing the v1 instance. For v2 instances, you can use the same process as v1 or use one of MySQL for PCF Tools


Powered by Zendesk