Q&A 1 How do you install and run MySQL locally using XAMPP?

1.1 Explanation

XAMPP is a free, open-source web server stack that bundles Apache, MySQL (MariaDB), PHP, and Perl. It lets you set up a local environment in minutes β€” no complex server setup required.

For beginners and researchers, this is an easy way to learn SQL and test databases locally before deploying to cloud platforms.

πŸ‘‰ Note: XAMPP uses MariaDB, a drop-in replacement for MySQL. It behaves almost the same as MySQL, with extra features and performance improvements.


1.2 Prerequisites

  • Download and install XAMPP: https://www.apachefriends.org
  • Open the XAMPP Control Panel
  • Start these services:
    • MySQL Database (required)
    • Apache Web Server (optional, for phpMyAdmin and web apps)

1.3 πŸ”‘ Accessing MySQL/MariaDB in XAMPP (macOS)

Once MySQL is running, you have two ways to work with it:

1.3.1 πŸ“Œ Option 1: phpMyAdmin (GUI)

This web interface is convenient for:

  • Creating and dropping databases
  • Running SQL queries with a query editor
  • Browsing and editing data visually

1.3.2 πŸ’» Option 2: MySQL/MariaDB Command Line (CLI)

If you prefer terminal commands, open your macOS terminal:

# Step into the XAMPP MySQL directory (where the MariaDB binary lives)
cd /Applications/XAMPP/bin

# (Optional, first-time only) Make the mysql binary executable
chmod +x mysql

# Launch the MariaDB shell as the root user
# Note: By default in XAMPP, the root user has no password
./mysql -u root

When it works, you should see a welcome screen like this:

Welcome to the MariaDB monitor.  Commands end with ; or \g.
Your MariaDB connection id is 324
Server version: 10.4.28-MariaDB Source distribution

Copyright (c) 2000, 2018, Oracle, MariaDB Corporation Ab and others.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

MariaDB [(none)]> 

This prompt means you’re inside the MySQL/MariaDB shell and can run SQL commands directly.

βΈ»

1.4 βœ… Learning Outcome

By the end of this Q&A, you will be able to:

  • Install and run MySQL/MariaDB locally with XAMPP
  • Access MySQL through phpMyAdmin (GUI) or via the MariaDB CLI
  • Recognize the MariaDB shell prompt and know when the server is ready for queries

1.5 🧠 Takeaway

XAMPP makes databases accessible to everyone.
Use phpMyAdmin for easy GUI-based interaction, but practice the CLI to build confidence in real-world workflows.