SQL Notes
Step-by-step guide to downloading and installing MySQL on Windows, macOS, and Linux, including MySQL Workbench setup and first connection verification.
Before you can write SQL queries and build databases, you need a database server running on your machine. MySQL is one of the most popular choices for learning SQL — it is free, well-documented, and used by companies like Facebook, Twitter, and YouTube. This guide walks you through installing MySQL step by step on any operating system.
Installing MySQL on Windows
Step 1: Download the Installer
Go to the official MySQL downloads page at https://dev.mysql.com/downloads/installer/ and download the MySQL Installer for Windows. Choose the full installer (not the web installer) for a smoother experience.
Step 2: Run the Installer
Double-click the downloaded .msi file. When the installer opens:
- Choose Custom installation type (gives you control over what gets installed)
- Select these components:
- MySQL Server (latest version)
- MySQL Workbench
- MySQL Shell
- Connector/J (if you plan to use Java)
Step 3: Configure the Server
The installer will ask you to configure MySQL Server:
- Config Type: Choose "Development Computer" (uses less memory)
- Port: Keep the default
3306 - Authentication: Use "Strong Password Encryption" (recommended)
- Root Password: Set a strong password and remember it. This is your admin password.
- Windows Service: Check "Configure MySQL Server as a Windows Service" and "Start at System Startup"
Step 4: Verify Installation
Open MySQL Workbench. You should see a connection tile labeled "Local instance MySQL." Click it, enter your root password, and you should see the query editor.
Test with:
SELECT VERSION();If you see a version number like 8.0.xx, MySQL is installed and running.
Installing MySQL on macOS
Method 1: Using the DMG Installer
- Go to
https://dev.mysql.com/downloads/mysql/and download the DMG for macOS - Open the DMG file and run the installer package
- Follow the wizard — it installs MySQL to
/usr/local/mysql/ - At the end, you will see a temporary root password. Copy it immediately.
- Open System Preferences and find the MySQL panel. Start the server.
Method 2: Using Homebrew (Recommended)
If you have Homebrew installed, this is simpler:
# Install MySQL
brew install mysql
# Start the MySQL service
brew services start mysql
# Secure the installation (set root password)
mysql_secure_installationInstall MySQL Workbench on macOS
Download from https://dev.mysql.com/downloads/workbench/ and drag it to your Applications folder.
Verify Installation
Open Terminal and run:
mysql -u root -pEnter your password. If you see the mysql> prompt, you are connected.
SELECT VERSION();
SHOW DATABASES;Installing MySQL on Linux (Ubuntu/Debian)
Step 1: Update Package List
sudo apt updateStep 2: Install MySQL Server
sudo apt install mysql-serverStep 3: Secure the Installation
sudo mysql_secure_installationThis interactive script asks you to:
- Set a root password
- Remove anonymous users
- Disable remote root login
- Remove the test database
- Reload privilege tables
Answer Yes to all for a secure setup.
Step 4: Verify the Service
sudo systemctl status mysqlYou should see "active (running)."
Step 5: Connect
sudo mysql -u root -pSELECT VERSION();
SHOW DATABASES;First Steps After Installation
Once MySQL is running, verify everything works by creating a test database:
-- Create a test database
CREATE DATABASE test_db;
-- Switch to it
USE test_db;
-- Create a simple table
CREATE TABLE greetings (
id INT PRIMARY KEY AUTO_INCREMENT,
message VARCHAR(100),
created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP
);
-- Insert some data
INSERT INTO greetings (message) VALUES ('Hello, MySQL!');
INSERT INTO greetings (message) VALUES ('SQL is working!');
-- Query the data
SELECT * FROM greetings;If you see your messages displayed in a table, congratulations — MySQL is fully set up and ready for learning.
Setting Up MySQL Workbench
MySQL Workbench is the recommended GUI tool for writing and testing queries:
- Open MySQL Workbench after installation
- Create a new connection (or use the default Local instance)
- Connection Name:
Local MySQL - Hostname:
127.0.0.1 - Port:
3306 - Username:
root
- Test Connection — click the button to verify it works
- Open the connection — you will see the SQL editor where you can write queries
Workbench Tips for Beginners
- Use
Ctrl+Enter(orCmd+Enteron Mac) to execute the current statement - Use
Ctrl+Shift+Enterto execute all statements in the editor - The "Schemas" panel on the left shows all your databases and tables
- Right-click a table to see its structure or data
Creating a Practice User
For security, avoid using the root account for everyday work. Create a dedicated practice user:
-- Create a new user
CREATE USER 'student'@'localhost' IDENTIFIED BY 'YourPassword123';
-- Grant full access to a practice database
CREATE DATABASE practice;
GRANT ALL PRIVILEGES ON practice.* TO 'student'@'localhost';
FLUSH PRIVILEGES;Now connect to MySQL Workbench using the student account for your learning exercises.
Common Installation Issues
Issue: "Access denied for user 'root'" You are using the wrong password. On macOS DMG installs, check for the temporary password shown during installation.
Issue: "Can't connect to MySQL server on localhost" The MySQL service is not running. Start it:
- Windows: Open Services, find MySQL, click Start
- macOS: System Preferences > MySQL > Start
- Linux:
sudo systemctl start mysql
Issue: "Port 3306 already in use" Another MySQL instance or another service is using port 3306. Stop the conflicting service or change MySQL's port in the configuration file.
Issue: MySQL Workbench cannot find the server Make sure the hostname is 127.0.0.1 (not localhost) and the port is 3306.
What is Next?
Now that MySQL is installed, you are ready to:
- Create your first real database
- Design tables with proper constraints
- Insert, query, update, and delete data
- Practice SQL queries from this course
Keep MySQL Workbench open as your workspace — it is where you will write and test all your SQL throughout this course.
Exam Focus
Revise definitions, diagrams, examples, and short-answer points for Install MySQL on Your Computer.
Interview Use
Prepare one clear explanation, one practical example, and one common mistake for this SQL Complete Guide topic.
Search Terms
sql-complete-guide, sql complete guide, sql, complete, guide, setup, install, mysql
Related SQL Complete Guide Topics