MySQL Introduction


🔹 What is MySQL?

MySQL is an open-source relational database management system (RDBMS). It is used to store, manage, and retrieve data for web applications and enterprise software.

MySQL is developed, distributed, and supported by Oracle Corporation and is one of the most popular databases used with PHP, Java, and Python.


🔹 Why Use MySQL?

  • Open-source and free to use

  • Fast, reliable, and scalable

  • Supports large databases and complex queries

  • Integrates well with PHP and web servers

  • Powerful SQL language support for querying and managing data


🔹 What is SQL?

SQL (Structured Query Language) is the standard language used to communicate with MySQL databases. SQL allows you to:

  • Create and modify database structures (tables, columns)

  • Insert, update, delete, and query data

  • Manage users, permissions, and transactions


🔹 Basic MySQL Syntax Example

SELECT * FROM customers;
 
 

This command retrieves all records from the customers table.


🔹 Common SQL Commands in MySQL

Command Description
SELECT Retrieve data from a table
INSERT INTO Add new data into a table
UPDATE Modify existing data
DELETE Remove records
CREATE TABLE Define a new table
ALTER TABLE Modify table structure
DROP TABLE Delete a table

🔹 Connecting MySQL with PHP

<?php
$servername = "localhost";
$username = "root";
$password = "";
$dbname = "test";

$conn = mysqli_connect($servername, $username, $password, $dbname);

if (!$conn) {
  die("Connection failed: " . mysqli_connect_error());
}
echo "Connected successfully";
?>
 

Practice Questions

Q1. Create a table for storing student records

Q2. Insert a record into the students table

Q3. Retrieve all records from the students table

Q4. Update a student's grade

Q5. Delete a student from the table


Go Back Top