Lesson 1 of 15

Introduction to MySQL

What is MySQL?

MySQL is the world's most popular open-source relational database management system (RDBMS). It was created in 1995 by Michael Widenius and David Axmark, acquired by Sun Microsystems in 2008, and then by Oracle in 2010. Despite corporate ownership, MySQL remains open-source under the GPL license, and a community fork called MariaDB was created by the original authors to keep it fully open.

Where is MySQL Used?

MySQL powers a significant portion of the internet:

  • WordPress — The most popular CMS in the world uses MySQL by default.
  • Facebook — Started on MySQL and still uses it for some workloads at massive scale.
  • Twitter — Used MySQL for core data storage in its early years.
  • Wikipedia — The encyclopedia runs on MySQL (via MariaDB).
  • Airbnb, GitHub, Netflix — All use MySQL or MariaDB in production.

The classic LAMP stack (Linux, Apache, MySQL, PHP) built the early web and remains in widespread use today.

Relational Databases

MySQL is a relational database. Data is organized into tables, which are like spreadsheets with rows and columns. Tables relate to each other through foreign keys.

For example, a store database might have:

TableWhat it stores
productsItem catalog with prices
customersPeople who buy things
ordersPurchase transactions
order_itemsLine items within each order

This structure avoids duplicating data. Instead of storing a customer's name on every order, you store a customer_id that points back to the customers table.

SQL — Structured Query Language

You interact with MySQL using SQL (Structured Query Language). SQL is a declarative language: you describe what you want, and the database figures out how to get it.

The most fundamental SQL statement is SELECT:

SELECT * FROM products;

This reads as: "Give me all columns (*) from the products table."

MySQL vs. Other Databases

FeatureMySQLPostgreSQLSQLite
LicenseGPL / CommercialPostgreSQL (BSD-like)Public domain
ServerYesYesNo (embedded)
SpeedVery fast readsBalancedFastest for local use
JSONSupportedNative (JSONB)Limited
Full-text searchBuilt-inBuilt-in (tsvector)FTS extension
Use caseWeb apps, OLTPAnalytics, complex queriesLocal/embedded

The Exercise Database

Throughout this course, you will work with a store database containing four tables:

TableColumns
productsid, name, price, category, stock
customersid, name, email, city
ordersid, customer_id, total, status, order_date
order_itemsid, order_id, product_id, quantity, unit_price

Your Task

Select all columns from the products table to see what data you are working with.

MySQL runtime loading...
Loading...
Click "Run" to execute your code.