1 of 23

Activity:

Terminal, Docker, and MySQL

Mark Fontenot, PhD

Northeastern University

2 of 23

Getting to Know Your Computer a Little Better

  • Most popular OSs provide you with a graphical user interface (GUI).
    • Generally, an event-driven model of interaction
      • you click on a button or an icon and something happens
  • BUT, not the only way to interact with your OS.
  • You can use a CLI (Command Line Interface) to interact with your computer.

2

3 of 23

Some Terms

  • Terminal (Console) - a text-based I/O device connected to a computer (think old-school, green screen, just text)
  • Terminal Emulator - a software program that acts like a terminal
  • Shell - a program that runs via a terminal and allows interaction via text-based commands
    • sh, bash, zsh, fish, etc.

3

4 of 23

Pictures Included

4

Terminal

Terminal Emulator

Point of Confusion: The name of the Mac Terminal Emulator is simply “Terminal”.

5 of 23

Standard CLI for Windows

  • Command Prompt
    • from the days of DOS
    • provides a set of commands�similar those provided by *NIX shells
  • PowerShell is a more modern command shell for Windows
    • includes a scripting language like Bash and Zsh

5

6 of 23

WSL Linux Shell

  • WSL2 (should have installed with Docker) provides a full Linux shell environment
  • Commands in WSL2/Linux and Mac (for our purposes) are going to be more or less the same
  • Linux file system is separated from Windows file system
    • Windows file system is available at /mnt

6

7 of 23

The File System

  • Files and directories�are organized in a �hierarchy
  • Each user of a system (usually) has a home directory
  • When you launch a shell, it usually starts in your home directory
  • pwd (present working directory) - command that will tell you where you are in the file system.

7

8 of 23

Paths

  • absolute path
    • starts with a /
    • the path lists all directories to a resource starting at the root of the file system
  • relative path
    • does NOT start with a /
    • the path lists directories to get to a resource starting at the current working directory

8

9 of 23

Moving Around the File System

  • ls
    • lists the files in the current directory
  • cd <return>
    • takes you to your home directory
  • cd directory_name<return>
    • moves into the directory whose name you’ve provided.
    • that directory must be in the current directory
  • cd ..<return>
    • moves into the parent directory of current folder
  • cd /<return>
    • moves to the root of the file system.
  • cd ~<return>
    • move to your home directory

9

10 of 23

Making Directories and Empty Files

  • mkdir new_dir_name<return>
    • makes a new directory inside current dir with name new_dir_name
  • mkdir -p dir1/dir2/dir3<return>
    • creates intermediate directories as required
  • touch file_name<return>
    • creates an empty file named file_name

10

11 of 23

Your Turn!

  1. Open a Mac Terminal or WSL2 Terminal
  2. Make sure that you’re in your home folder (use pwd to confirm)
  3. Make a directory named CS3200
  4. Move into the CS3200 directory
  5. Make a folder named day01
  6. Create an empty file named example.sql

11

12 of 23

Docker & MySQL

12

13 of 23

Docker

  • Docker provides the ability to package and run an application in a loosely isolated environment called a container.

13

14 of 23

What is MySQL?

  • Most one of the most popular open source RDBMS
  • Currently developed, distributed, and supported by Oracle (but still open source)
  • Fast, reliable, scalable
  • (Typically) deployed in a client/server setup
    • but there is an embedded version
  • MariaDB is a fork of MySQL by original MySQL devs… released under GNU GPL.

14

15 of 23

Client/Server Model of MySQL

15

MySQL Server

The Network/Internet

16 of 23

During Software Dev…

In a typical developer stack, the dev might need to have an instance of MySQL running on their machine…

Options:

- Direct Install

- Prepackaged executable (like XAMPP, etc)

- Containerization or VM

16

MySQL Server

17 of 23

Enter…. Docker!

  • Docker is a containerization platform
  • Allows you to package software into standardized units
    • ease of development
    • ease of shipment
    • ease of deployment
  • Container is similar to, but not exactly the same as, a virtual machine
  • Very widely used in industry
  • We’ll be using Docker Desktop
    • one click install of the Docker Engine, Docker CLI, Docker Compose and some other tools

17

18 of 23

Start Docker Desktop… Pull Mysql

18

19 of 23

Pause while MySQL Downloads

19

20 of 23

20

unused

21 of 23

21

MYSQL_ROOT_PASSWORD

abc123

You can put any

password here

you want

22 of 23

In Data Grip

  • New Data�source!

22

Use the password you entered on the previous step of creating the container

23 of 23

Follow along with Demo to Add Northwind

23