Deploying Laravel 5 Applications on Shared Hosting Part 2
In the first part of this post here we successfully published our Laravel 5 application to a shared host. In this post, we will continue with the deployment of our application by migrating our local database to the remote host.
Before we proceed to migrate our database from the local host to the remote host, we first need to create our database on the remote host.
Open your CPanel on the remote host and click on the MySQL Database Wizard. It will prefix your database with your host name. Type in the name of the database and click next step. In the next step, create the database users by entering a username and password and then click on create user. In the next page, assign the user all privileges on the database. Remember the username and password you have created because you will need it in the later.
On your local host, open your phpmyadmin and navigate to your database and click on export. Save the generated sql file. On the CPanel of your remote host click on phpmyadmin navigate to the database you created earlier and click on import, click choose file, navigate to the folder where you save the sql file you exported in you local machine, grab the file and click on import.
This will import the tables you have in your local database to your remote database. If you click on your remote database now, you will see all the tables that were in your local database in your remote database now.
It is time to modify and upload the .env file now with your remote database credentials. Open the .env file, enter the name of the database you created just like the illustration below:
DB_CONNECTION=mysql DB_HOST=localhost DB_PORT=3306 DB_DATABASE=database_name DB_USERNAME=username DB_PASSWORD=password
Once you have done this, you can use an FTP client to upload the .env file to the root of your application as demonstrated in part 1 of this post.
That's all you need to do and hopefully, your tables and database are setup correctly.
If you have any questions or comments, kindly add a comment below and I will get back to you.