Skip to main content
Albero Academy

MySQL Fundamentals

What MySQL is, connecting to a server, creating databases and tables, and choosing the right data types.

Chapter 1MySQL14 min readBeginner friendly
  • #MySQL
  • #Basics

MySQL is the world's most popular open-source relational database — the "M" in the classic LAMP stack and the store behind countless web apps. It speaks SQL, so the querying you learn in the SQL course applies directly; this course focuses on the MySQL server itself: creating databases, its data types, keys, and its performance tools.

What is MySQL?

A relational database stores data in tables of rows and columns, with relationships between tables. MySQL is the server that holds those tables and answers SQL queries. You talk to it from a terminal client, a GUI like MySQL Workbench, or from application code.

Connecting

From the command line, connect with the mysql client:

terminal
mysql -u root -p # -u user, -p prompts for the password
# then, at the mysql> prompt:
SHOW DATABASES;
USE mydb;
SHOW TABLES;

Databases & tables

Create a database, switch into it, then define tables. A table declares each column's name, type and constraints:

create a schema
CREATE DATABASE albero;
USE albero;
CREATE TABLE students (
id INT AUTO_INCREMENT PRIMARY KEY,
name VARCHAR(100) NOT NULL,
email VARCHAR(150) UNIQUE,
enrolled DATE,
package DECIMAL(5,2) DEFAULT 0.00,
created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP
);
  • PRIMARY KEY uniquely identifies each row; AUTO_INCREMENT fills it automatically.
  • NOT NULL requires a value; UNIQUE forbids duplicates; DEFAULT supplies a fallback.

Data types

Picking the right type keeps data correct and storage small:

TypeUse for
INT / BIGINTWhole numbers, ids
DECIMAL(p,s)Exact money/measures (never FLOAT for money)
VARCHAR(n)Short, variable-length text
TEXTLong text (articles, notes)
DATE / DATETIMEDates and timestamps
BOOLEANTrue/false (stored as TINYINT)
ENUM(...)One value from a fixed set

Practice

Create an albero database with a programmes table (id, name, duration_months, fee) and a students table. Choose sensible types and constraints, then DESCRIBE each table to inspect it.

Key takeaways

  1. 01MySQL is an open-source relational database server that speaks SQL.
  2. 02Connect with the mysql client (or Workbench); CREATE DATABASE then USE it.
  3. 03Every table should have a PRIMARY KEY — usually an AUTO_INCREMENT INT id.
  4. 04Constraints (NOT NULL, UNIQUE, DEFAULT) keep data valid at the database level.
  5. 05Match the type to the data: DECIMAL for money, VARCHAR for short text, DATE/DATETIME for time.