Here’s a clear, step-by-step guide to creating a database and tables using XAMPP and phpMyAdmin, perfect for beginners.


https://youtu.be/QVMyMGg08DA?si=p98bB7M4E_m41C_S

1. Install and Start XAMPP

  1. Download XAMPP from apachefriends.org
  2. Install it (default settings are fine)
  3. Open XAMPP Control Panel
  4. Start:
    • Apache
    • MySQL

When both turn green, XAMPP is running.


2. Open phpMyAdmin

  1. Open your browser
  2. Go to: http://localhost/phpmyadmin

phpMyAdmin is the web interface for managing MySQL databases.


3. Create a Database

  1. In phpMyAdmin, click Databases (top menu)
  2. Under Create database:
    • Enter a database name (example: school_db)
    • Choose collation: utf8mb4_general_ci
  3. Click Create

Your database is now created.


4. Create Tables (Using UI Method)

  1. Click your database name (school_db) on the left panel
  2. Under Create table:
    • Table name: students
    • Number of columns: 5
  3. Click Go

Example Table Structure

Column NameTypeLengthExtra
idINT11PRIMARY KEY, AUTO_INCREMENT
nameVARCHAR100
emailVARCHAR100UNIQUE
ageINT3
created_atTIMESTAMP
  1. Click Save

Table created successfully!


5. Create Tables (Using SQL Query – Recommended)

  1. Select your database
  2. Click SQL
  3. Paste this example:
CREATE TABLE students (
    id INT(11) AUTO_INCREMENT PRIMARY KEY,
    name VARCHAR(100) NOT NULL,
    email VARCHAR(100) UNIQUE,
    age INT(3),
    created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP
);
  1. Click Go

Table created using SQL.


6. Insert Data into Table

Using SQL

INSERT INTO students (name, email, age)
VALUES ('John Doe', 'john@example.com', 20);

7. View Table Data

  1. Click your table (students)
  2. Select Browse

You’ll see the inserted records.


8. Common Errors & Fixes

ProblemSolution
MySQL not startingClose other MySQL services (e.g., MySQL Server)
phpMyAdmin errorRestart Apache & MySQL
Database not showingRefresh phpMyAdmin

9. Folder Location for PHP Files

Place your PHP files in:

C:\xampp\htdocs\

Access them via:

http://localhost/yourfile.php