Connecting mysql database with laravel app in heroku
https://medium.com/@ajshantudas/connecting-mysql-database-with-laravel-app-in-heroku-5d593b60847a
Last updated
https://medium.com/@ajshantudas/connecting-mysql-database-with-laravel-app-in-heroku-5d593b60847a
Last updated
Shantu Chandra DashFollowOct 30, 2018 · 2 min readheroku
My last post was about how to host your laravel application in heroku. If you are new to this blog then this is highly recommended to checkout my previous blog.How do you publish your laravel application in Heroku ?what is Heroku ?medium.com
If you already know how to deploy your laravel app then just follow this tutorial to connect with database.
To log in use command $heroku login
Enter your email and password.
There is a heroku add-on called ClearDB that provides mysql heroku support to your laravel app. To create your ClearDB database just hit this command.
This will create a free database. To show your database information use command line.
This command will give you something like that, don’t worry to write it down because this information will be passed on as an environment variable. If you want connect with mysql workbench or mysql pro, you can use this information to connect your database. Just use your information properly and use 3306 as your port number.
Go to your laravel project and navigate to app\config\database.php
and paste this lines of code before returning any database configuration.
create a connection like this
and, use your_heroku_mysql_connection as your default database connections
Your, database config should be like this
That’s it.
Thanks for taking your time to read, I do hope the article has helped you! If you liked this article don’t forget to clap.
Happy coding ✌
3