MySQL

The dependable workhorse on nearly every shared host.

What is it?

MySQL is one of the world's most widely deployed relational databases. It stores data in tables, speaks SQL, and has been the "M" in the classic LAMP stack (Linux, Apache, MySQL, PHP) for decades — which is why it comes pre-installed on virtually every shared hosting plan, usually with the phpMyAdmin web interface for managing it.

It's rock-solid, fast for the read-heavy workloads typical of websites, and so common that nearly every tutorial, CMS, and hosting panel assumes it.


When to use it

MySQL is the natural pick on shared hosting — it's already there, already configured, and pairs perfectly with PHP. It handles structured data (users, products, posts) extremely well and is a great first "real" database because the SQL you learn transfers everywhere. For zero-setup local learning, SQLite is even simpler; for feature depth and large-scale growth, PostgreSQL has the edge.


Core concepts
  • Databases and tables — a MySQL server hosts multiple databases; each database holds tables with typed columns (VARCHAR, INT, DATETIME…).
  • Users and privileges — apps connect with a username/password that's granted access to a specific database. Hosting panels create these for you.
  • AUTO_INCREMENT keys — the standard way to give every row a unique id automatically.
  • Storage engine (InnoDB) — the modern default; it gives you transactions and foreign keys. You rarely change it, but it's good to know the name.
  • phpMyAdmin — the browser-based admin tool on most shared hosts: create tables, browse rows, and run queries without touching a terminal.

A taste of the code
CREATE TABLE guestbook (
  id         INT AUTO_INCREMENT PRIMARY KEY,
  author     VARCHAR(100) NOT NULL,
  message    TEXT NOT NULL,
  created_at DATETIME DEFAULT CURRENT_TIMESTAMP
);

INSERT INTO guestbook (author, message)
VALUES ('Sam', 'First post!');

SELECT author, message FROM guestbook
ORDER BY created_at DESC;

Standard SQL — create a table, add a row, read it back. This exact pattern is behind most contact forms and comment sections on the web.


Your first steps
  1. Learn SQL basics — they're 90% of using MySQL.
  2. Get MySQL running: on a shared host it's one click in the control panel; locally, XAMPP bundles MySQL with PHP and phpMyAdmin.
  3. Open phpMyAdmin, create a database and a table, and insert a few rows through the interface.
  4. Connect from code — PDO in PHP or mysql2 in Node.js — using prepared statements for any user input.
  5. Build a guestbook or blog: a form that inserts rows and a page that lists them.

← Back to Stack Picker All primers