Installation & Setup
Before you can create the StreamHub database, you need a MySQL server running somewhere and a way to talk to it. There are several equally valid ways to get there depending on your operating system and how much you already have installed — this lesson walks through the main routes and the tools you'll use to actually connect and run commands.
Installing MySQL Directly
The most direct route is downloading MySQL Community Server — the free, open-source edition of MySQL — straight from MySQL's own site and running its installer. On Linux, it's usually faster to go through your distribution's package manager instead. On a Debian- or Ubuntu-based system:
sudo apt update
sudo apt install mysql-server
On macOS, using Homebrew:
brew install mysql
brew services start mysql
On Windows, the official MySQL Installer bundles the server, the command-line client, and optionally MySQL Workbench into one download, and walks you through setting an initial root password during setup.
The Easy Route: XAMPP, WAMP, and Similar Stacks
If you're following along from this site's PHP track, there's a very good chance you already have MySQL running without realizing you "installed" it separately. All-in-one local stacks like XAMPP and WAMP bundle Apache, PHP, and MySQL (or MariaDB) together and start them all with one control panel. This site's own XAMPP Setup lesson walks through getting that stack running on Windows step by step — if you've already done that lesson, you can skip straight to connecting below, because MySQL is already there and waiting.
Server vs. Client: Two Different Things
It's worth being precise about a distinction that trips a lot of beginners up. The MySQL
server (the mysqld process) is a background program you start once
and leave running — it listens quietly for connections and does nothing on its own besides
that. A MySQL client is a completely separate program you open whenever you
actually want to send it a command: create a database, run a SELECT, whatever. You
don't reinstall or restart the server every time you want to run a query — you just open a
client, connect, and start typing.
Three Ways to Connect and Run Queries
Once a server is running somewhere, you have several equally valid ways to actually talk to it.
| Tool | What it is |
|---|---|
The mysql CLI | A text-based command-line client that ships with every MySQL install. You type SQL directly and see raw text results. Fast, always available, and what most of this track's examples assume. |
| MySQL Workbench | A full graphical desktop application with a visual schema designer, a query editor with autocomplete, and built-in tools for browsing table data without typing a single SELECT. |
| phpMyAdmin | A web-based admin tool you open in a browser, commonly bundled with PHP hosting and with XAMPP/WAMP — see this site's PHP track for more on the stack it typically ships alongside. |
A Full Worked Example: Connecting via the CLI
Once MySQL is installed and the server is running, open a terminal and connect as the
root user (the default administrative account created during installation):
mysql -u root -p
You'll be prompted for the root password you set during installation. After entering it
correctly, the prompt changes to mysql>, meaning you're now inside an active
MySQL session. From there, try listing every database currently on the server:
SHOW DATABASES;
A typical fresh install responds with something like this:
| Database |
|---|
| information_schema |
| mysql |
| performance_schema |
| sys |
Those four are internal databases MySQL creates and manages for itself — you won't touch them
directly in this track. Once streamhub shows up in this list in the next lesson,
you'll know it worked.
Setting or Resetting the Root Password
If you ever need to change the root password from inside a session, MySQL's own statement for it looks like this (replace the placeholder with a real password of your own):
ALTER USER 'root'@'localhost' IDENTIFIED BY 'your_new_password';
If you've forgotten the root password entirely, most distributions document a "safe mode" recovery procedure that temporarily disables permission checks so you can reset it — that process is OS-specific enough that it's outside the scope of this lesson.
A Brief Word on Remote Connections
Everything above assumes MySQL is running on the same machine you're working on. In real
deployments, it's just as common to connect to a MySQL server on a completely different
machine — a database server on your network, or a managed database in the cloud — by adding a
-h host flag: mysql -u root -p -h db.example.com. Connecting remotely
brings its own set of concerns around which users are allowed to connect from where, which is
covered properly once we reach Users & Privileges
and Security Best Practices later in this track.
streamhub database itself.