Using MySQL

SQL Home MySQL Product Page

MySQL is the world's leading open-source Relational Database Management System (RDBMS) or simply, relational database. MySQL is installed by default on many Linux distributions as well as MacOS; it also available for Windows. MySQL is included in your environment (which is a Linux-based system).

We will be using a sample student information system (SIS) database for the remainder of this unit. Click here to download a backup (or dump) of that database.

Create a new folder in your 376 project on called sql. Once your download is complete, upload that file the sql folder. The rest of your work will be done in the terminal window.

Extracting the ZIP File in Terminal

  1. Go to the folder that contains the ZIP file: cd 376/sql
  2. View the contents of that folder: ls -la
  3. Unzip the file: unzip
  4. View the contents of that folder (again): ls -la
  5. Look a the contents of the SQL file: more sis_database.sql

Using MySQL in Terminal

  1. Start the MySQL service: sudo service mysql start
  2. Start the MySQL client: mysql -u root
  3. Restore a database from a backup: source [insert name of SQL file here]
  4. Show available databases: show databases;
  5. Use a particular database: use [insert database name here];
  6. Show tables within the active database: show tables;
  7. Show details for a particular table: desc [insert table name here];
  8. Quit the MySQL client: quit