Environment Setup: SQL Server, SSMS and Databases
Introduction
While you can practice SQL directly on CodePeet without any setup, having a local SQL environment gives you the freedom to experiment with your own databases and explore advanced features.
In this tutorial, you will learn:
- Options for practicing SQL locally
- How to set up SQL Server and SSMS (Windows)
- Alternative options for Mac and Linux users
- How to connect to a database
- Creating your first local database
Note: This setup is optional. All course exercises run directly in your browser on CodePeet.
Local Setup Options
Several options exist for running SQL on your local machine.
Option Comparison
| Option | OS Support | Difficulty | Best For |
|---|---|---|---|
| SQLite | All | Easy | Quick start, learning |
| SQL Server + SSMS | Windows | Medium | Enterprise SQL, T-SQL |
| PostgreSQL + pgAdmin | All | Medium | Open source, advanced features |
| MySQL + Workbench | All | Medium | Web development, widely used |
| Docker containers | All | Medium-Hard | Multiple databases, flexibility |
| Cloud databases | All (web) | Easy | Production-like environments |
Recommendations by Goal
| If You Want To... | Use This |
|---|---|
| Learn SQL basics quickly | SQLite or CodePeet |
| Work with enterprise databases | SQL Server + SSMS |
| Use open-source production database | PostgreSQL + pgAdmin |
| Develop web applications | MySQL + Workbench |
| Have maximum flexibility | Docker |
Our Recommendation for This Course
Use CodePeet for course exercises - Everything runs in browser.
For local practice:
- Windows users → SQL Server Express + SSMS
- Mac/Linux users → PostgreSQL + pgAdmin or SQLite
SQLite - Simplest Option
SQLite is the easiest way to start practicing SQL locally. It requires no server setup.
What is SQLite?
- Self-contained: Entire database is a single file
- Zero-configuration: No server process to manage
- Cross-platform: Works on Windows, Mac, Linux
- Standard SQL: Compatible with this course's syntax
Installation
Windows:
- Download from https://www.sqlite.org/download.html
- Choose "sqlite-tools-win32-x86" (Precompiled Binaries)
- Extract to a folder (e.g., C:\sqlite)
- Add folder to PATH environment variable
Mac:
# SQLite is pre-installed on Mac
# Verify with:
sqlite3 --version
Linux:
# Ubuntu/Debian
sudo apt-get install sqlite3
# Fedora/RHEL
sudo dnf install sqlite
Basic Usage
# Create/open a database
sqlite3 mydatabase.db
# Inside SQLite:
sqlite> CREATE TABLE users (id INTEGER PRIMARY KEY, name TEXT);
sqlite> INSERT INTO users (name) VALUES ('Alice');
sqlite> SELECT * FROM users;
sqlite> .exit
GUI Options for SQLite
| Tool | Platform | Notes |
|---|---|---|
| DB Browser for SQLite | All | Free, easy to use |
| DBeaver | All | Free, universal database tool |
| SQLiteStudio | All | Free, feature-rich |
| TablePlus | All | Free tier available, modern UI |
SQL Server Express + SSMS (Windows)
Microsoft SQL Server is widely used in enterprise environments. The Express edition is free for learning.
What You'll Install
- SQL Server Express - The database engine (free edition)
- SQL Server Management Studio (SSMS) - The graphical interface
Step 1: Download SQL Server Express
- Go to: https://www.microsoft.com/en-us/sql-server/sql-server-downloads
- Scroll to "Express" edition
- Click "Download now"
- Run the installer
Step 2: Installation Options
When the installer opens, choose:
Basic (Recommended for beginners)
- Simplest installation
- Uses default settings
- Quick setup
Custom (For more control)
- Choose installation location
- Select specific features
- Configure instance name
Step 3: During Installation
| Setting | Recommendation |
|---|---|
| Instance Name | Keep default (SQLEXPRESS) |
| Authentication | Windows Authentication |
| Install Path | Use default unless disk space is limited |
Step 4: Download SSMS
- After SQL Server installs, download SSMS
- Or go to: https://learn.microsoft.com/en-us/sql/ssms/download-sql-server-management-studio-ssms
- Run the SSMS installer
- Follow prompts (mostly "Next")
Step 5: Connect to Your Server
- Open SQL Server Management Studio
- In "Connect to Server" dialog:
- Server type: Database Engine
- Server name:
localhost\SQLEXPRESSor.\SQLEXPRESS - Authentication: Windows Authentication
- Click "Connect"
Verification
Once connected, you should see:
- Object Explorer panel on the left
- Your server listed with databases
- System databases (master, model, msdb, tempdb)
PostgreSQL + pgAdmin (All Platforms)
PostgreSQL is a powerful open-source database that runs on all platforms.
Step 1: Download PostgreSQL
- Go to: https://www.postgresql.org/download/
- Choose your operating system
- Download the installer from EnterpriseDB (recommended)
Step 2: Installation
Run the installer and configure:
| Setting | Recommendation |
|---|---|
| Installation Directory | Use default |
| Data Directory | Use default |
| Password | Remember this! (for postgres superuser) |
| Port | 5432 (default) |
| Locale | Default |
| Components | Select all (includes pgAdmin) |
Step 3: Using pgAdmin
pgAdmin is included with PostgreSQL installation.
- Open pgAdmin 4
- Click on "Servers" in left panel
- Right-click → "Register" → "Server"
- Configure:
- General tab → Name: "Local PostgreSQL"
- Connection tab:
- Host: localhost
- Port: 5432
- Username: postgres
- Password: (your password from installation)
- Click "Save"
Step 4: Create a Database
- Right-click on "Databases"
- Select "Create" → "Database"
- Enter database name (e.g., "practice")
- Click "Save"
Step 5: Open Query Tool
- Right-click on your database
- Select "Query Tool"
- Write SQL in the query panel
- Click "Execute" (or F5) to run
PostgreSQL-Specific Syntax Notes
| Feature | PostgreSQL | SQL Server |
|---|---|---|
| String concat | || | + |
| Current date | CURRENT_DATE | GETDATE() |
| Limit rows | LIMIT 10 | TOP 10 |
| Auto-increment | SERIAL | IDENTITY |
MySQL + Workbench
MySQL is one of the most popular open-source databases, especially for web applications.
Step 1: Download MySQL Community Server
- Go to: https://dev.mysql.com/downloads/mysql/
- Choose your operating system
- Download the installer
Step 2: Download MySQL Workbench
- Go to: https://dev.mysql.com/downloads/workbench/
- Choose your operating system
- Download the installer
Alternatively, use the MySQL Installer (Windows) which includes both.
Step 3: Installation
Run the MySQL Installer:
| Setting | Recommendation |
|---|---|
| Setup Type | Developer Default (includes Workbench) |
| Root Password | Set and remember! |
| MySQL User Accounts | Create if needed |
| Windows Service | Yes, start at system startup |
Step 4: Using MySQL Workbench
- Open MySQL Workbench
- Click on your local connection (usually already configured)
- Enter password when prompted
- Write SQL in the query tab
- Click lightning bolt (⚡) to execute
Step 5: Create a Database
-- Create a new database
CREATE DATABASE practice;
-- Switch to the database
USE practice;
-- Create a table
CREATE TABLE users (
id INT AUTO_INCREMENT PRIMARY KEY,
name VARCHAR(100),
email VARCHAR(100)
);
MySQL-Specific Syntax Notes
| Feature | MySQL | Standard SQL |
|---|---|---|
| Auto-increment | AUTO_INCREMENT | IDENTITY (varies) |
| String concat | CONCAT() | || |
| Backticks | Used for identifiers | Not standard |
Creating Your First Database
Once your environment is set up, let's create a simple practice database.
Universal SQL Example
This example works on most database systems with minor modifications:
-- Create a new database (syntax may vary)
CREATE DATABASE practice;
-- Use the database
-- SQL Server: USE practice;
-- PostgreSQL: \c practice (or use GUI)
-- MySQL: USE practice;
-- SQLite: sqlite3 practice.db
-- Create a customers table
CREATE TABLE customers (
customer_id INTEGER PRIMARY KEY,
name TEXT NOT NULL,
email TEXT,
city TEXT,
created_at DATETIME DEFAULT CURRENT_TIMESTAMP
);
-- Create an orders table
CREATE TABLE orders (
order_id INTEGER PRIMARY KEY,
customer_id INTEGER,
order_date DATE,
total_amount DECIMAL(10,2),
FOREIGN KEY (customer_id) REFERENCES customers(customer_id)
);
-- Insert sample data
INSERT INTO customers (customer_id, name, email, city) VALUES
(1, 'Alice Johnson', 'alice@mail.com', 'New York'),
(2, 'Bob Smith', 'bob@mail.com', 'Los Angeles'),
(3, 'Carol Davis', 'carol@mail.com', 'Chicago');
INSERT INTO orders (order_id, customer_id, order_date, total_amount) VALUES
(101, 1, '2024-01-15', 150.00),
(102, 1, '2024-01-20', 89.99),
(103, 2, '2024-01-18', 299.00),
(104, 3, '2024-01-22', 45.50);
-- Test query
SELECT c.name, COUNT(o.order_id) AS order_count, SUM(o.total_amount) AS total_spent
FROM customers c
LEFT JOIN orders o ON c.customer_id = o.customer_id
GROUP BY c.customer_id, c.name
ORDER BY total_spent DESC;
Expected Output
| name | order_count | total_spent |
|---|---|---|
| Bob Smith | 1 | 299.00 |
| Alice Johnson | 2 | 239.99 |
| Carol Davis | 1 | 45.50 |
Troubleshooting Common Issues
Here are solutions to common setup problems.
SQL Server Issues
Cannot connect to server
Error: Cannot connect to localhost\SQLEXPRESS
Solutions:
- Verify SQL Server service is running:
- Open "Services" (services.msc)
- Find "SQL Server (SQLEXPRESS)"
- Ensure it's running
- Try alternative server names:
.\SQLEXPRESS(local)\SQLEXPRESS127.0.0.1\SQLEXPRESS
- Check SQL Server Configuration Manager for TCP/IP settings
PostgreSQL Issues
Authentication failed
Error: password authentication failed for user "postgres"
Solutions:
- Double-check password (case-sensitive)
- Reset password via command line:
sudo -u postgres psql ALTER USER postgres PASSWORD 'newpassword';
Connection refused
Error: Connection refused on port 5432
Solutions:
- Check PostgreSQL service is running
- Verify port 5432 is not blocked by firewall
MySQL Issues
Access denied
Error: Access denied for user 'root'@'localhost'
Solutions:
- Verify password is correct
- Reset root password:
mysql -u root --skip-password ALTER USER 'root'@'localhost' IDENTIFIED BY 'newpassword';
SQLite Issues
'sqlite3' is not recognized
Solutions:
- Add SQLite folder to system PATH
- Or use full path to sqlite3.exe
General Tips
- Restart services after configuration changes
- Check logs for detailed error messages
- Firewall settings may block database connections
- Run as Administrator when installing (Windows)
Cloud Alternatives
If local installation is problematic, cloud databases offer an alternative.
Free Cloud Options
| Service | Database | Free Tier |
|---|---|---|
| Supabase | PostgreSQL | 500MB, generous limits |
| PlanetScale | MySQL | 5GB, serverless |
| Neon | PostgreSQL | 3GB, serverless |
| ElephantSQL | PostgreSQL | 20MB (limited) |
| CockroachDB | CockroachDB (PostgreSQL compatible) | 10GB |
AWS Free Tier
Amazon RDS offers 12 months free:
- 750 hours of db.t2.micro instance
- MySQL, PostgreSQL, MariaDB, SQL Server options
- Requires AWS account and credit card
Google Cloud
Cloud SQL offers:
- $300 free credits for new accounts
- MySQL, PostgreSQL, SQL Server options
Benefits of Cloud Databases
- No installation - Runs in browser
- Accessible anywhere - Any device with internet
- Automatic backups - Data is safe
- Scalable - Grow as needed
Drawbacks
- Requires internet connection
- May have usage limits on free tiers
- Some features may be paid only
Practice
Before setting up a local environment, practice these queries on CodePeet to understand what you'll be able to do locally.
Exercise 1: Explore Table Structure
Use SQLite's PRAGMA command to see table information. This type of command helps you understand your database structure.
-- Explore the structure of the customers table
-- This helps you understand what columns exist
PRAGMA table_info(olist_customers_dataset);Exercise 2: List All Tables
Query the SQLite master table to see all available tables. This is one of the first things you do when exploring a new database.
-- List all tables in the database
-- Use this to explore what data is available
SELECT name AS table_name
FROM sqlite_master
WHERE type = 'table'
ORDER BY name;Exercise 3: Sample Data Query
Preview data from a table. This is the type of query you'll run often when exploring databases.
-- Preview data from the products table
-- A simple query to understand what data looks like
SELECT
product_id,
product_category_name,
product_weight_g
FROM olist_products_dataset
LIMIT 10;Summary
You now know how to set up a local SQL environment!
Key Takeaways
✅ CodePeet works without setup - Practice directly in browser
✅ SQLite - Simplest local option, no server needed
✅ SQL Server + SSMS - Best for Windows and enterprise SQL
✅ PostgreSQL + pgAdmin - Best open-source option for all platforms
✅ MySQL + Workbench - Great for web development focus
✅ Cloud alternatives - No installation required
Setup Checklist
For this course:
- Access CodePeet (✅ already done!)
For local practice (optional):
- Choose a database system
- Download and install database engine
- Download and install management tool
- Connect to your local server
- Create a practice database
What's Next?
You've completed the Introduction to SQL module! You now understand:
- What databases and SQL are
- How DBMS systems work
- Different types of databases
- SQL command categories
- Why SQL skills are valuable
- How to set up a local environment
Continue to Module 2: SELECT Queries to start writing real SQL queries!