December 2017
Beginner to intermediate
376 pages
7h 53m
English
When you installed the ClearDB add-on, a new environment variable, CLEARDB_DATABASE_URL, was automatically set. Let's read its value using the heroku config:get command:
$ heroku config:get CLEARDB_DATABASE_URL # mysql://b221344377ce82c:398z940v@us-cdbr-iron-east-03.cleardb.net/heroku_n0b30ea856af46f?reconnect=true
In a Laravel project, the database is connected by setting values for DB_HOST and DB_DATABASE. We can extract the values for these from the CLEARDB_DATABASE_URL variable, which is in the form:
mysql://[DB_USERNAME]:[DB_PASSWORD]@[DB_HOST]/[DB_DATABASE]?reconnect=true
Once you've extracted the values, set the applicable environment variables in the Heroku app:
$ heroku config:set \ DB_HOST=us-cdbr-iron-east-03.cleardb.net ...
Read now
Unlock full access