Skip to content
This repository has been archived by the owner. It is now read-only.
Branch: master
Find file History
Fetching latest commit鈥
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
..
Failed to load latest commit information.
static
view
.gitignore
index.js
package.json
readme.md

readme.md

MySQL Server

An express-server but with a mysql database.

Install

First, get the example:

git clone git@github.com:cmda-be/course-17-18.git
cd course-17-18/examples/mysql-server
npm install

Then, log into mysql:

mysql -u your-username -p
# Enter your password

鈥nd run the following SQL to set up a database and populate a movies table:

CREATE DATABASE IF NOT EXISTS mymoviewebsite;
USE mymoviewebsite;
CREATE TABLE IF NOT EXISTS movies (
  id INT NOT NULL AUTO_INCREMENT,
  cover TEXT CHARACTER SET utf8,
  title TEXT CHARACTER SET utf8,
  description TEXT CHARACTER SET utf8,
  plot TEXT CHARACTER SET utf8,
  PRIMARY KEY (id)
);
-- Add some movies like so:
INSERT INTO movies (title, plot, description) VALUES (
  'Evil Dead',
  'Five friends travel to a cabin in 鈥',
  'Five friends head to a remote cabin, 鈥'
);
INSERT INTO movies (title, plot, description) VALUES (
  'The Shawshank Redemption',
  'Two imprisoned men bond over a 鈥',
  'Andy Dufresne is a young and 鈥'
);

Now, add a .env file with the following info (replacing the values with actual values):

DB_HOST=localhost
DB_USER=myusername
DB_NAME=mydatabase
DB_PASSWORD=mypassword

Finally, start the server with:

npm start

Changes

The following commits show how this example was created:

License

MITTitus Wormer

You can鈥檛 perform that action at this time.