These instructions assume you have MySQL Community Server and MySQL Workbench installed. If not: https://dev.mysql.com/doc/workbench/en/wb-installing.html
-
Open up MySQL Workbench and create a new connection if one is not already made.
To do this, press the + next to MySQL Connections. Name the connection anything you like, and set the password if you had set one during configuring the installation. You can test the connection with the Test Connection button, then confirm by pressing OK.
-
Connect to your server with the connection you have by clicking on it once.
-
On the left, you should see a navigation box with Management, Instance, and Performance. At the bottom of the box, you can see Schemas. Click the little icon of two arrows facing away from each other to the right of Schemas.
The box now shows you what databases (schemas) are in your server. There might be none now, but that's okay.
-
Now we can create a new database for our server.
Right click the navigation box and select Create Schema...
Name it anything, for example test, then click Apply. You'll get a pop up to review the code that actually creates the database. You can simply press Apply once more.
-
Next, we are going to create tables with the given .sql files located in our nodeApp folder in the files that you cloned from GitHub.
Up at the top navigation bar with File, Edit, etc., go to Server and click Data Import.
Select the option, Import from Self-Contained File and then click the icon with the ''..." on the right to navigate to the nodeApp folder with the .sql files, listings.sql and t_user.sql.
After selecting one of the files, below where you clicked Import from Self-Contained File, you can select a Default Target Schema. In this case, it is the database that you created earlier.
-
Repeat the process for the other .sql file.
-
You are finished setting up the database! From now on, all you need to remember is how to import .sql files for future testing.
-
Open up the server.js file in the nodeApp folder.
-
On line 26 and 27, you'll see
password : '', database : 'test',
Change 'test' to whatever you named your database earlier on, and set the password if you have one on your server.
-
Open up your terminal and navigate to the folder with the server.js file in it and run it.
node server.js
-
Open up a browser and do localhost:3000 for the url.
-
Try out the search. If you type in Mas Banyar in user search, you should get similar names that start with Mas. In listings search, type in San Francisco and you should also get similar cities that start with San.
Note that the search only works if you press the button. Don't press enter in the search bar! We'll get around to implementing that.
โ