Skip to content

MySQL

What is MySQL? (Beginner → Pro)

MySQL is a relational database management system (RDBMS). In simple words: it is software used to store, organize, and retrieve data in a structured way.

  • Uses SQL (Structured Query Language)
  • Very fast, reliable, and widely used
  • Open-source (free)
  • Commonly used in web apps, backend systems, and APIs

Popular apps using MySQL: WordPress, Facebook (earlier), YouTube (earlier), e-commerce sites, dashboards.


What is a Database?

A database is like a smart Excel sheet but:

  • Handles millions of rows
  • Supports multiple users at once
  • Secure and fast
  • Can be queried using SQL

Example data:

  • Users (id, name, email, password)
  • Orders (order_id, user_id, amount)
  • Products (name, price, stock)

What is MySQL Server?

MySQL Server is the actual running service that:

  • Listens for requests
  • Stores data on disk
  • Executes SQL queries
  • Manages users, permissions, backups

Think of it like:

MySQL Server = Engine that runs the database

It usually runs in the background on:

  • localhost
  • Port 3306

What is the root User?

  • root is the admin (superuser) of MySQL
  • Has full access:

  • Create/delete databases

  • Create users
  • Grant permissions
  • Read/write all data

⚠️ Important:

  • root is powerful
  • Not recommended for production apps

What Does user: root and password: root Mean?

This means:

  • Username = root
  • Password = root

Example login:

mysql -u root -p

Then enter:

root

⚠️ This setup is:

  • OK for learning / local development
  • ❌ NOT safe for production

Why Is MySQL Used?

Engineers use MySQL because:

  • Easy to learn
  • Extremely stable
  • Works with almost every language:

  • Node.js

  • Java
  • PHP
  • Python
  • C / C++
  • Huge ecosystem & community
  • Excellent performance for structured data

How Engineers Use MySQL (Typical Flow)

  1. App sends request (login, fetch data)
  2. Backend runs SQL query
  3. MySQL Server returns result
  4. App responds to user

Example SQL:

SELECT * FROM users WHERE email = 'test@example.com';

MySQL vs File Storage

Feature MySQL Files
Speed Fast Slow
Search Powerful (SQL) Limited
Security Strong Weak
Concurrency Multi-user Poor
Scaling Easy Hard

Beginner → Advanced Path

Beginner

  • SELECT, INSERT, UPDATE, DELETE
  • Tables & rows
  • Primary keys

Intermediate

  • Indexes
  • Joins
  • Transactions
  • Constraints

Advanced

  • Replication
  • Sharding
  • Performance tuning
  • Backups & recovery

MySQL in Real Projects

  • Backend APIs
  • Authentication systems
  • Analytics dashboards
  • SaaS products
  • E-commerce platforms