Connecting your MySQL-Heroku application to Xeround Cloud Database
There are two ways to use Xeround Cloud Database with your MySQL-Heroku application:
- Using the Xeround Cloud Database Add-on for Heroku
- Connecting your Heroku application to your external Xeround database instance
See below for instructions and code samples for connecting your Heroku application to use Xeround Cloud Database:
If you are using the Heroku Add-on:
- Add the Xeround Cloud Database Add-on to your Heroku Environment
- Install the Xeround add-on:
$ heroku addons:add xeround:plan_name
Valid values for plan_name are:
- free
- basic100
- basic250
- pro512
Note: As database provisioning is carried out asynchronously, please wait until the creation and initialization of the database complete. You can monitor the progress of this process by clicking the Xeround add-on in the Add-ons menu of your application’s Resources.
- Connect your Heroku application to Xeround:
- Upon provisioning the Xeround Heroku Add-On to your Heroku environment, you will receive two database URLs, labeled XEROUND_DATABASE_URL and XEROUND_DATABASE_INTERNAL_URL. The first URL is used for connecting to your database from outside the datacenter (Amazon-EC2-US-East), and the “INTERNAL” URL is translated to internal IP addresses and should be used when accessing your database from within the same datacenter. The INTERNAL URL is what you’d most often use for connecting to your cloud database.
- Copy the value of the config variable that is relevant for you:
$ heroku config:add DATABASE_URL=(copied value of the config variable)
**Note:**
Round-robin DNS is used on all of Xeround’s instances and guarantees high availability of the connection to your database in a way that does not require you to tweak your application. Therefore, the config variable XEROUND_DATABASE_FAILOVER_URL that was provided in previous releases is no longer required. For backward compatibility it is set with the same value as XEROUND_DATABASE_URL
Each of the URLs contains a string of the following syntax:
mysql://username:password@host:port/database
- The parts out of which the URLs are made of are also set for your convenience in the following environment variables:
XEROUND_DATABASE_ADAPTER XEROUND_DATABASE_USERNAME XEROUND_DATABASE_PASSWORD XEROUND_DATABASE_HOST XEROUND_DATABASE_PORT XEROUND_DATABASE_NAME XEROUND_DATABASE_INTERNAL_ADAPTER XEROUND_DATABASE_INTERNAL_USERNAME XEROUND_DATABASE_INTERNAL_PASSWORD XEROUND_DATABASE_INTERNAL_HOST XEROUND_DATABASE_INTERNAL_PORT XEROUND_DATABASE_INTERNAL_NAME
If you created your cloud database via Xeround:
- Sign up to Xeround
- From the online console, choose “Create New” to create your new database instance.
Select your preferred Database Plan- From the “Data Center” drop-down list, select “Amazon-EC2-US-East” or “Amazon-EC2-EU-West”, depending on where your Heroku app is deployed. Having both the application and your database on the same data center minimizes latency.
- Continue to fill in the information required for creating your database then click “Create”.
- Connect to your new cloud database using an external tool, such as phpMyAdmin (also available from your Xeround online console) and create your database / schema.
Note: On the Details tab in the online console you see the two DNS hostnames provided for your database. Usually you would use the “Internal DNS name”- which is used for connecting to your database from within the same datacenter. The “External DNS hostname” is used for connecting from outside the datacenter. Clicking any of the connection URLs would log you in to phpMyAdmin where you can create your schema.
- Edit the connection string of your MySQL-Heroku app to connect to Xeround’s Cloud Database:
mysql://username:password@host:port/database
- username – this is the username you chose when you created your database in step #2 above
- password – this is the password you chose when you created your database in step #2 above
- host:port – these are the DNS hostnames displayed to you in the “Details” tab shown above
- database – this is the database/schema name you chose when you created your database (step #3 above)
You may also wish to check out Xeround Cloud Database User Guide.

