Skip to main content
MySQL Basics
CHAPTER 02 Beginner

Installing MySQL and phpMyAdmin

Updated: May 16, 2026
6 min read

# CHAPTER 2

Installing MySQL and phpMyAdmin

1. Introduction

To learn MySQL, you need a safe sandbox environment to practice in. You don't want to buy an expensive cloud database server just to learn the basics. Instead, you can turn your own laptop into a local web server! In this chapter, we will install the complete MySQL engine along with a beautiful visual interface called phpMyAdmin, using a free software bundle called XAMPP.

2. Learning Objectives

By the end of this chapter, you will be able to:
  • Understand what a Localhost server is.
  • Install XAMPP (Apache and MySQL) on Windows, macOS, or Linux.
  • Start and stop the MySQL database engine.
  • Access the visual database manager, phpMyAdmin.
  • Access the MySQL Command Line Interface (CLI).

3. What is Localhost?

When you go to google.com, your browser connects to a remote server. When you type localhost into your browser, your browser connects to your own computer. It tells your machine to act as both the client and the server simultaneously. This is the ultimate, free testing environment for web developers.

4. The Magic of XAMPP

Installing the raw MySQL engine, configuring user permissions, and linking it to a web server manually is incredibly frustrating for beginners. XAMPP is a free software bundle that installs everything you need in one click:
  • X (Cross-Platform)
  • A (Apache - The Web Server)
  • M (MySQL/MariaDB - The Database Engine)
  • P (PHP - The Backend Language)
  • P (Perl)

5. Installation Guide

For Windows:
  1. 1. Go to apachefriends.org and download XAMPP for Windows.
  1. 2. Run the installer. Leave all default settings checked.
  1. 3. Open the XAMPP Control Panel.
  1. 4. Click the "Start" button next to Apache and MySQL.
*(If they turn green, your database server is officially running!)*

For macOS:

  1. 1. Download XAMPP for OS X from apachefriends.org.
  1. 2. Open the .dmg file and drag it to Applications.
  1. 3. Open the XAMPP Control Panel and start Apache and MySQL.
*(Alternatively, Mac users can download MAMP, which is highly optimized for macOS).*

For Linux (Ubuntu): Run the following in your terminal to install the native LAMP stack without XAMPP: sudo apt update sudo apt install mysql-server sudo systemctl start mysql

6. Accessing phpMyAdmin

Writing raw SQL code in a black terminal window is intimidating. phpMyAdmin is a free, web-based graphical user interface (GUI) that allows you to manage your MySQL databases using your mouse!
  1. 1. Ensure Apache and MySQL are running in your XAMPP Control Panel.
  1. 2. Open your web browser (Chrome/Firefox).
  1. 3. Type the following URL into the address bar:
http://localhost/phpmyadmin
  1. 4. Press Enter. You should see a beautiful dashboard showing your current databases!

7. Accessing the MySQL CLI (Command Line)

While phpMyAdmin is great for visual management, real developers must know how to write raw SQL commands. We use the Command Line Interface (CLI).

On Windows (via XAMPP):

  1. 1. Open the XAMPP Control Panel.
  1. 2. Click the "Shell" button on the right side.
  1. 3. A black terminal will appear. Type the following command and press Enter:
mysql -u root -p
  1. 4. It will ask for a password. By default, XAMPP has no password. Just press Enter again.
  1. 5. You should now see the MariaDB [(none)]> or mysql> prompt. You are inside the database engine!

8. Mini Project: Verify Installation

Let's run a quick command in the CLI to see all the default databases installed on your system.
sql
12345678910111213
-- At the mysql> prompt, type this and press Enter:
SHOW DATABASES;

-- Output should look similar to:
-- +--------------------+
-- | Database           |
-- +--------------------+
-- | information_schema |
-- | mysql              |
-- | performance_schema |
-- | phpmyadmin         |
-- | test               |
-- +--------------------+

*Note: Always end your SQL commands with a semicolon ;!*

9. Common Mistakes

  • Port Conflicts: If MySQL refuses to start in the XAMPP control panel and turns red, it usually means another program (like Skype or an old installation of MySQL) is already using Port 3306. You must stop the other program first.
  • Forgetting the Semicolon: In the CLI, if you type SHOW DATABASES without a semicolon and press Enter, nothing will happen. The engine thinks you are still typing on the next line. Type ; and press Enter to execute.

10. Best Practices

  • Never expose XAMPP to the internet: XAMPP is explicitly designed as a *development* tool. It is inherently insecure (the root database user has no password by default). Never use XAMPP to host a live, production website on the open internet.

11. Exercises

  1. 1. Open phpMyAdmin in your browser. Look at the left sidebar. What are the names of some of the default databases created by the system?
  1. 2. Open the MySQL CLI and write the command to display all current databases.

12. MCQ Quiz with Answers

Question 1

What is the primary purpose of phpMyAdmin?

Question 2

When using the default XAMPP installation, what is the default username and password for the MySQL database?

13. Interview Questions

  • Q: Explain what the acronym LAMP stack stands for and the role each component plays in web development.
  • Q: Why do developers prefer to run a local database environment (like XAMPP/Localhost) during the initial phases of building an application rather than a live cloud database?

14. FAQs

Q: Why does my CLI say "MariaDB" instead of "MySQL"? A: MariaDB is a "fork" (a cloned, highly compatible version) of MySQL created by the original developers of MySQL after it was purchased by Oracle. For 99.9% of commands and use cases, MariaDB and MySQL are exactly identical. XAMPP packages MariaDB by default.

15. Summary

You have successfully transformed your personal computer into a powerful web and database server. By installing XAMPP, you gain access to both the robust MySQL Command Line Engine for writing code, and the intuitive phpMyAdmin dashboard for visual management. Your sandbox is ready.

16. Next Chapter Recommendation

Before we start aggressively creating tables and inserting data, we must understand *how* tables are supposed to relate to each other. In Chapter 3: Understanding Relational Databases, we will explore the theory of database normalization and table relationships.

Finish this Chapter

Save your progress on your learning path and prepare for coding interview challenges.

Discussion

Join the discussion

Log in or create a free account to participate.

Sort: ·