Step by step React, NodejS and MySQL Simple Full Stack Application 2018 (part: 6)

kmaryam27

Maryam Keshavarz

Posted on April 1, 2019

Step by step React, NodejS and MySQL Simple Full Stack Application 2018 (part: 6)

In this article I try to solve bugs of part 5, upload it on Github and show the project on heroku.com.

Now we can style it and improve the project step by step by before all we try to deploy first version of project to the Github and Heroku. First: Go to Github.com and make an account for your project Github is a web-based hosting service for version control using Git. It is mostly used for computer code. It offers all of the distributed version control and source code management (SCM) functionality of Git as well as adding its own features. It provides access control and several collaboration features such as bug tracking, feature requests, task management, and wikis for every project. Open client folder in terminal and with npm run build command make it ready to deploy: Open your GitHub account and go to repository tab and press new button to make a new repository for your project:

Type your Repository name and add Initialize this repository with a README whith checklist, then pess .gitignore button to ignore node-module folder to deploy, So download and upload project will be faster but remember after download project with (npm install) command in VSCode terminal should add node-module folder with all requirements of project. Type Node on textBox and press Create Repository button:

Now open an account on heroku website (Heroku is a platform as a service (PaaS) that enables developers to build, run, and operate applications entirely in the cloud: www.heroku.com)

Then on your dashboard push new button to and then create new app button for setting up heroku new app


In the next step:

Now in the Deploy tab click on github button and on search place try to find your github repository



Then push connect button.
Now on the buttom of page click on (Enable automatic deploys) to automatcally deploys your app after change on github.
The next step is going to the resource tap and add mysql database on heroku app.
Remember to add jawsDB mysql free version:

Then with click on mysql go to another page to access heroku mysql username and password:

Now we have to copt the connection string and paste it inside of our project as a mySql database address, so below code on line 33-38 of app.js:

const connection = mysql.createConnection({
  host: 'localhost',
  user:'root',
  password:'myjs123',
  database:'simple-react-sql-db'
});

Enter fullscreen mode Exit fullscreen mode

should change to host user password and database address of connection String.
Now test your application to make sure it is working.
we have to see this error because we have not user table on new database to map it now. So on your MySQL workbench go to home tab to add your heroku database on it and add your table on new database:

Now in localhost database with copy table and paste table statement on heroku app database we can have that table on heroku:


Now insert your data to database:

The last change is on the backend routes folder in html-routes.js file. we have to change database name to heroku app database:

Test again your application, it is working without any error.
Now we have to build the project ...

💖 💪 🙅 🚩
kmaryam27
Maryam Keshavarz

Posted on April 1, 2019

Join Our Newsletter. No Spam, Only the good stuff.

Sign up to receive the latest update from our blog.

Related