MySQL Introduction

Understanding MySQL database fundamentals

🗄️ What is MySQL?

MySQL is an open-source relational database management system that uses SQL (Structured Query Language). It organizes data into tables with rows and columns, making data storage and retrieval efficient and reliable.


-- Simple MySQL query example
SELECT database_name 
FROM information_schema.schemata;
                                    

Key MySQL Features

🔒

Secure

MySQL provides robust security features including user authentication, encrypted connections, and access control. It protects your data with password encryption and privilege management to ensure only authorized users can access sensitive information.

📊

Scalable

MySQL handles everything from small applications to massive enterprise systems. It scales efficiently to manage millions of records and supports high-traffic websites. You can start small and grow without changing your database system.

🔄

ACID Compliant

MySQL ensures data integrity through ACID properties (Atomicity, Consistency, Isolation, Durability). Transactions are processed reliably, preventing data corruption. If something goes wrong, changes can be rolled back to maintain database consistency.

🌍

Cross-Platform

MySQL runs on multiple operating systems including Windows, Linux, macOS, and Unix. This flexibility allows you to develop on one platform and deploy on another. It integrates seamlessly with various programming languages and frameworks.

🔹 MySQL History

MySQL was created in 1995 by Swedish developers Michael Widenius and David Axmark. The name combines "My" (co-founder's daughter's name) with SQL. Oracle Corporation acquired MySQL in 2010, continuing its development as open-source software.

MySQL Timeline:

  • 1995: MySQL first released
  • 2000: Became open-source under GPL
  • 2008: Sun Microsystems acquired MySQL
  • 2010: Oracle acquired Sun Microsystems
  • Present: Most popular open-source database

🔹 How MySQL Works

MySQL uses a client-server architecture. The server stores and manages databases while clients send requests to retrieve or modify data. The server processes SQL queries and returns results, enabling multiple users to access data simultaneously.

-- Connect to MySQL server
mysql -u username -p

-- Show available databases
SHOW DATABASES;

-- Create a new database
CREATE DATABASE my_store;

-- Use the database
USE my_store;

Output:

Database changed

🔹 MySQL Components

MySQL consists of several key components working together. The server manages data storage and processing. Storage engines handle how data is stored. The query optimizer improves performance by finding the most efficient way to execute queries.

Main Components:

  • MySQL Server: Core database engine that processes requests
  • Storage Engines: InnoDB (default), MyISAM, Memory
  • Query Optimizer: Improves query execution speed
  • Connection Handler: Manages client connections
  • SQL Interface: Processes SQL commands

🔹 MySQL Use Cases

MySQL powers diverse applications from small blogs to large e-commerce platforms. It's ideal for web applications, content management systems, data warehousing, and logging applications. Companies use MySQL for customer data, inventory management, and analytics.

-- Example: E-commerce product table
CREATE TABLE products (
    product_id INT PRIMARY KEY AUTO_INCREMENT,
    product_name VARCHAR(100),
    price DECIMAL(10, 2),
    stock_quantity INT
);

-- Add a product
INSERT INTO products (product_name, price, stock_quantity)
VALUES ('Laptop', 899.99, 50);

Output:

Query OK, 1 row affected (0.01 sec)

🧠 Test Your Knowledge

What does SQL stand for in MySQL?