Skip to content
Follow
CMS Windows

How to Install phpMyAdmin with Apache on Windows WSL

Richard
Written by
Richard
May 31, 2021 Updated Jul 21, 2026 7 min read
How to Reset Your Microsoft Account Password
How to Reset Your Microsoft Account Password

Installing phpMyAdmin with Apache on Windows WSL lets you manage your MySQL and MariaDB databases using a web browser.

⚡ Quick Answer

Install phpMyAdmin with Apache on Windows WSL by enabling WSL and Virtual Machine Platform features, installing Ubuntu from the Microsoft Store, then installing Apache and MariaDB within Ubuntu using apt commands.

phpMyAdmin is a free tool that makes database work easier by providing a friendly visual interface. It’s a great way to manage databases without needing to type complicated commands.

Setting up phpMyAdmin and Apache inside Windows Subsystem for Linux (WSL 2) is a smart move for anyone learning or working with databases. This setup, often using WSL 2, offers a simple way to control your data.

You can easily run commands, create new users for your databases, or make backups all from a webpage. This makes managing your databases much more straightforward on your Windows PC.

📋 Quick Steps
  1. First, turn on the Windows Subsystem for Linux (WSL) and the Virtual Machine Platform by running commands in PowerShell as an administrator.
  2. Next, install Ubuntu from the Microsoft Store. Open Ubuntu and create a username and password.
  3. Install the Apache web server in Ubuntu by typing sudo apt update then sudo apt install apache2 in your Ubuntu terminal.
  4. Install the MariaDB database server by typing sudo apt-get install mariadb-server mariadb-client in Ubuntu, then run sudo mysql_secure_installation to secure it.
  5. Install PHP, needed for phpMyAdmin, by typing sudo apt install php libapache2-mod-php php-common php-mysql php-gmp php-curl php-intl php7.4-mbstring php-xmlrpc php-gd php-xml php-cli php-zip into your Ubuntu terminal.
  6. Finally, install phpMyAdmin itself by typing sudo apt install phpmyadmin in Ubuntu. Follow the prompts to set it up with Apache and create a password.
  7. Open your web browser and go to http://localhost/phpmyadmin to log in and start managing your databases.

Getting Started

Step 1Enable WSL in Windows

To run Linux programs like phpMyAdmin on your Windows computer, you must first enable the Windows Subsystem for Linux (WSL). This involves opening PowerShell as an administrator and running a command to enable this essential Windows feature. It’s the first step to getting phpMyAdmin Windows WSL set up.

    1. Click the Start button and type PowerShell

    1. Right-click on Windows PowerShell and select Run as administrator ⚠️ Requires admin privileges

PowerShell terminal running as administrator for WSL setup
powershell administrator

In the PowerShell window, copy and paste this command:

dism.exe /online /enable-feature /featurename:Microsoft-Windows-Subsystem-Linux /all /norestart

You should see a success message like this:

Deployment Image Servicing and Management tool
Version: 10.0.19041.844
Image Version: 10.0.19042.844
Enabling feature(s)
[==========================100.0%==========================]
The operation completed successfully.

Step 2Enable Virtual Machine Platform

For your phpMyAdmin on Windows WSL setup to work well with WSL 2, you need to enable the Virtual Machine Platform. You do this by running a specific command in the administrator PowerShell window you already have open. This step is crucial for WSL 2 to function correctly.

In the same PowerShell window, copy and paste this command:

dism.exe /online /enable-feature /featurename:VirtualMachinePlatform /all /norestart

If you have Windows 10 version 2004 or older, use this command instead:

Enable-WindowsOptionalFeature -Online -FeatureName VirtualMachinePlatform -NoRestart

⚠️Warning
Now restart your computer to apply all changes.

After your computer restarts, open PowerShell as administrator again and run this command:

wsl --set-default-version 2

Step 3Install Ubuntu on Windows

Now that WSL and the Virtual Machine Platform are ready, you can install Ubuntu from the Microsoft Store to continue setting up phpMyAdmin on Windows WSL. Ubuntu is a popular Linux system that provides the environment for your tools. Search for Ubuntu in the Store, click ‘Get’, and then ‘Launch’ it.

You can download Ubuntu 20.04 LTS directly from the Microsoft Store by clicking this link: Get Ubuntu 20.04 LTS – Microsoft Store. This link provides the specific version of Ubuntu you need for your Windows Subsystem for Linux (WSL) installation.

Ubuntu installation on Windows WSL for phpMyAdmin
ubuntu windows wls install

Click the Get button and wait for it to install.

When done, click Launch to start Ubuntu for the first time.

Ubuntu will ask you to create a username and password. Choose anything you want:

Enter new UNIX username: user123
New password: (type your password)
Retype new password: (type it again)
passwd: password updated successfully
Installation successful!

You’ll see a welcome message from Ubuntu. This means it’s working!

Welcome to Ubuntu 20.04.2 LTS (GNU/Linux 4.4.0-19041-Microsoft x86_64)
System information as of Mon Apr 12 17:57:37 CDT 2021
System load: 0.52 Processes: 7
Memory usage: 26% IPv4 address for eth0: 192.168.1.100

If you run into problems, try these commands:

wsl --set-default-version 1
bcdedit /set hypervisorlaunchtype auto start

Step 4Install Apache Web Server

To host phpMyAdmin on Windows WSL and access it through your web browser, installing the Apache web server is necessary. Open your Ubuntu terminal and use the commands ‘sudo apt update’ followed by ‘sudo apt install apache2’ to get Apache installed and ready to go.

In Ubuntu, run these commands:

sudo apt update
sudo apt install apache2

⚠️ These commands require admin privileges (sudo)

To control Apache, use these commands:

sudo service apache2 stop (stops it)

sudo service apache2 start (starts it)

sudo service apache2 restart (restarts it)

Does it work? Open your web browser and go to:

http://localhost

You should see Apache’s test page.

LAMP stack setup on Windows WSL with Ubuntu
lamp windows wsl ubuntu

Step 5Install MariaDB Database Server

MariaDB is the database system that phpMyAdmin will use to store and manage your data safely. Install it within your Ubuntu environment using the apt package manager. Type ‘sudo apt-get install mariadb-server mariadb-client’ into your Ubuntu terminal to get both the server and client components.

Run these commands:

sudo apt-get install mariadb-server mariadb-client

⚠️ Requires admin privileges

To control MariaDB, use these commands:

sudo service mysql stop (stops it)

sudo service mysql start (starts it)

sudo service mysql restart (restarts it)

Now secure your database with a password:

sudo mysql_secure_installation

⚠️ Requires admin privileges

Answer the questions like this:

⚠️Warning
Enter current password for root (enter for none): Press Enter
Set root password? [Y/n]: Y
New password: (type your password)
Re-enter new password: (type it again)
Remove anonymous users? [Y/n]: Y
Disallow root login remotely? [Y/n]: Y
Remove test database and access to it? [Y/n]: Y
Reload privilege tables now? [Y/n]: Y

Did it work? Test by logging in to the database:

sudo mysql -u root -p

Type your password when asked. You should see:

Welcome to the MariaDB monitor. Commands end with ; or g.
Your MariaDB connection id is 46
Server version: 10.3.29-MariaDB-0ubuntu0.20.04.1 Ubuntu 20.04
MariaDB [(none)]>

Type exit to leave.

Step 6Install PHP

phpMyAdmin requires the PHP programming language to function, making its installation a vital step for your phpMyAdmin on Windows WSL setup. Run the command ‘sudo apt install php libapache2-mod-php php-common php-mysql php-gmp php-curl php-intl php7.4-mbstring php-xmlrpc php-gd php-xml php-cli php-zip’ in your Ubuntu terminal to install PHP and its necessary tools.

Run this command to install PHP and the tools it needs:

sudo apt install php libapache2-mod-php php-common php-mysql php-gmp php-curl php-intl php7.4-mbstring php-xmlrpc php-gd php-xml php-cli php-zip

⚠️ Requires admin privileges

Did it work? Check the PHP version:

php -v

You should see something like:

PHP 7.4.3 (cli) (built: Oct 6 2020 15:47:56) ( NTS )
Copyright (c) The PHP Group
Zend Engine v3.4.0, Copyright (c) Zend Technologies

To test PHP more thoroughly, create a test file:

sudo nano /var/www/html/phpinfo.php

⚠️ Requires admin privileges

Type this inside the file:

<?php phpinfo( ); ?>

Press Ctrl+X, then Y, then Enter to save.

Restart Apache:

sudo service apache2 restart

Now open your browser and go to:

http://localhost/phpinfo.php

You should see a page showing all your PHP information.

Testing PHP on Windows WSL with Apache server
lamp windows wsl php test

Step 7Install phpMyAdmin

phpMyAdmin is the web-based tool you’ll use to easily manage your MariaDB databases. To install it on your Windows WSL system, open your Ubuntu terminal and type ‘sudo apt install phpmyadmin’. When prompted, select Apache as your web server for the setup.

Run this command:

sudo apt install phpmyadmin

⚠️ Requires admin privileges

When asked which web server to use, select apache2 and press Enter.

Please choose the web server that should be automatically configured to run phpMyAdmin.
[*] apache2
[ ] lighttpd

When asked “Configure database for phpmyadmin with dbconfig-common?”, select Yes.

Create a password for phpMyAdmin when asked. Remember this password.

About root access: MariaDB has a security feature that can block the root user from logging into phpMyAdmin. If you need to use the root account, follow these steps:

Log into MariaDB:

sudo mysql

⚠️ Requires admin privileges

Run these commands:

USE mysql;
UPDATE user SET plugin='' WHERE user ='root';
FLUSH PRIVILEGES;
EXIT;

Restart Apache:

sudo service apache2 restart

Now open phpMyAdmin by going to:

http://localhost/phpmyadmin

Installing phpMyAdmin on Windows WSL environment
phpmyadmin windows wsl install

You should see a login page. Log in with your root username and password.

phpMyAdmin dashboard interface on Windows WSL
phpmyadmin windows wsl dashboard

You’re done! You can now manage your databases from phpMyAdmin.

Summary

You have now successfully installed phpMyAdmin with Apache on Windows WSL, setting up a powerful system for managing your databases. The process covered enabling WSL and Virtual Machine Platform, installing Ubuntu, Apache, MariaDB, and PHP, before finally installing phpMyAdmin itself.

    • Enabled WSL 2, which lets you run Linux on Windows

    • Installed Ubuntu, a Linux operating system

    • Installed Apache, a web server

    • Installed MariaDB, a database system

    • Installed PHP, a programming language

    • Installed phpMyAdmin, a web tool to manage databases

Now you have a powerful system for storing and managing data. You can use phpMyAdmin’s interface instead of typing complicated database commands.

Was this guide helpful?

Was this helpful?
Richard

About the Author

Richard

Tech Writer, IT Professional

Richard, a writer for Geek Rewind, is a tech enthusiast who loves breaking down complex IT topics into simple, easy-to-understand ideas. With years of hands-on experience in system administration and enterprise IT operations, he’s developed a knack for offering practical tips and solutions. Richard aims to make technology more accessible and actionable. He's deeply committed to the Geek Rewind community, always ready to answer questions and engage in discussions.

📚 Related Tutorials

How to Install phpMyAdmin on Windows 11 with WSL
Windows How to Install phpMyAdmin on Windows 11 with WSL
How to Set Windows Terminal to Open with Command Prompt on Windows 11
Windows How to Set Windows Terminal to Open with Command Prompt on Windows 11
How to Access Linux Files on Windows 11 Using WSL
Windows How to Access Linux Files on Windows 11 Using WSL
How to Mount Linux File System on Windows 11 via WSL
Ubuntu Linux How to Mount Linux File System on Windows 11 via WSL

0 Comments

  • thanks, that was helpful

    Reply
  • francisco

    Straight, clear. Very helpful
    Thank you

    Reply
  • ShoeRiderr

    Don’t use UPDATE user SET plugin=” WHERE user =’root’;

    It will broke your authentication system when you define password earlier

    Reply

Leave a Comment

Your email address will not be published. Required fields are marked *