Chapter 3: Installing and Setting Up MySQL Using XAMPP
Introduction
This chapter provides a step-by-step guide on installing and setting up MySQL using
XAMPP, a popular software package that simplifies the installation of a web server
environment. XAMPP includes Apache, MySQL, PHP, and Perl, making it an essential
tool for web development.
By the end of this chapter, students will understand how to install MySQL using
XAMPP, configure it, and verify its functionality by running basic SQL queries.
Objectives
• Guide through the installation process of MySQL using XAMPP.
• Configure MySQL Server and access it using phpMyAdmin and the Command
Line Interface (CLI).
• Verify a successful installation by running basic SQL queries.
What is XAMPP?
XAMPP is an open-source cross-platform software that includes:
• Apache (Web Server)
• MySQL (MariaDB) (Database Management System)
• PHP & Perl (Programming Languages)
MySQL (MariaDB) in XAMPP allows users to store and manage databases
conveniently without manually installing MySQL Server separately.
Downloading and Installing XAMPP
Step 1: Download XAMPP
1. Go to the official XAMPP website: https://www.apachefriends.org
2. Download the version compatible with your operating system (Windows,
macOS, or Linux).
1
Download Here:
URL: https://www.apachefriends.org/index.html
Step 2: Install XAMPP
Run the XAMPP Installer and follow the setup wizard.
Step 2.1: Click Next
2
Step 2.2: Click Next
Step 2.3: Click Next
3
Step 2.4: Click Next
Step 2.5: Click Next
4
Step 2.6: Wait until Unpacking files finish
Step 2.7: Click Allow access
5
Step 2.8: Click Finish
Finish Welcome to the XAMPP Control Panel
6
Configuring MySQL Server and Client Tools
Starting MySQL in XAMPP
1. Open XAMPP Control Panel.
2. Click Start next to MySQL.
3. MySQL is now running and ready to use.
Accessing MySQL
There are two ways to interact with MySQL in XAMPP:
1. Using phpMyAdmin (GUI)
7
2. Using MySQL Command Line (CLI)
Accessing MySQL via phpMyAdmin (GUI)
phpMyAdmin is a web-based interface for managing MySQL databases.
Steps to Open phpMyAdmin
1. Start Apache and MySQL in XAMPP Control Panel.
2. Open a web browser and go to: http://localhost/phpmyadmin/
3. The phpMyAdmin dashboard will open, allowing you to create and manage
databases easily.
8
Accessing MySQL via Command Line (CLI)
You can also interact with MySQL using the command-line interface.
Steps to Open MySQL CLI
1. Open XAMPP Control Panel.
2. Click the "Shell" button.
9
3. Type the following command to access MySQL: mysql -u root -p
CLI:
Press Enter (by default, XAMPP does not set a password for root).
10
Now, you are inside MySQL and can run SQL commands!
Verifying MySQL Installation with Basic SQL Queries
After installing and configuring MySQL, we need to test if it’s working properly
by running some basic SQL queries.
Query Syntax: Show databases;
This command Show databases; show all the existing databases created
from MariaDB.
11
Creating a Database:
Query Syntax: CREATE DATABASE SchoolDB;
This command creates a new database named SchoolDB.
12
Using the Database
Query Syntax: USE SchoolDB;
This command selects the SchoolDB database so that any further queries
apply to it.
Creating a Table
Query Syntax : CREATE TABLE Students (
Student_ID INT PRIMARY KEY,
Name VARCHAR(100),
Age INT
);
13
This explanation
• Student_ID INT PRIMARY KEY → Unique identifier for each student.
• Name VARCHAR(100) → Stores student names (up to 100 characters).
• Age INT → Stores student age as a number.
Inserting Data into the Table
Query Syntax: INSERT INTO Students (Student_ID, Name, Age)
VALUES (1, 'John Doe', 20);
14
This command adds a student record to the Students table.
Checking the Data:
Query Syntax: SELECT * FROM Students;
If you see this output, MySQL is working correctly!
Troubleshooting Common Installation Issues
15
What Should Students Learn?
• Understand the MySQL installation process on different operating systems.
• Install MySQL using XAMPP for an easy and quick setup.
• Start and configure the MySQL server using XAMPP Control Panel.
• Access MySQL using phpMyAdmin (GUI) and Command Line Interface (CLI).
• Create and manage databases through MySQL commands.
• Run basic SQL queries to verify a successful installation.
• Troubleshoot common installation issues to ensure MySQL runs smoothly.
16