How to install a MySQL Heroku Add-on and use it with Codeigniter 3.x
This is a guide to follow up to Deploying a PHP and MySQL web app with Heroku. So we’ve created a new Heroku app and done the necessary, now let’s install MySQL. First, open your apps listing here and choose the app you want to install MySQL on. You should see something like this
In the Add-ons search field, type ClearDB MySQL and select it. Choose the free plan (Ignite) and click provision. So now you’ve got MySQL installed, now we need to set it up so the app uses our local database.php file on our machine when we deploy to heroku. Go to your apps listing on heroku and choose your app. Click on the Settings tab. You should now see a config tab like in the picture below.
Reveal Config Varsand copy the
I’ll use mine as an example:
Everything after the @ symbol until the / is the
Everything after / until ? is
The string after the // until : is the
The string between : and @ is the
Now that we have our heroku DB credentials, let’s update our database.php file so that the app can access the ClearDB database when deployed to heroku.
My credentials now look like this.
Now we can
git add . && git commit -m "Added DB Config", and afterwards we can run
git push heroku master.
And just like that, you have a working staging environment with a MySQL database ready to go.
Note: ClearDB has an auto-increment value of 10 so the record ID’s will range from 2, 12, 22 and so on. The Ignite plan has a maximum database size of 5MB.
Like this article? Follow @LK_wapiti on Twitter