Do you manage MySQL servers and databases? If so, you know the pain of managing them via the command line. If you ever wished for a GUI-based management tool for MySQL, then you should consider phpMyAdmin.
phpMyAdmin is a web-based open-source tool written in PHP designed to help manage MySQL database through the Web browser. Because of this PhpMyAdmin facilitates the management and maintenance of the MySQL database.
Simply put, everything you can do from the MySQL command line, you can do in phpMyAdmin. Stay tuned; this article will teach you how to install phpMyAdmin on your Windows Server 2022 or Windows 11.
Table of Contents
Requirements
- An existing MySQL Server installation. The server could be on Windows or Linux.
- A Windows desktop or server where you’ll install phpMyAdmin. This tutorial uses Windows Server 2022 and Windows 11.
Note. You can install IIS, MySQL, and phpMyAdmin on the same Windows machine. This tutorial uses a separate computer for the IIS and phpMyAdmin installation.
Enabling the IIS Web Server
phpMyAdmin is a website written in PHP. In this case, your IIS installation must be PHP-capable for installing the phpMyAdmin website. The default IIS installation plus the CGI support should suffice.
You may skip this step if you already have an existing IIS web server installation.
On Windows Server (2016, 2019, 2022)
If you’re using Windows Server 2016 to 2022, you can enable the base IIS web server feature with CGI by running this command in PowerShell as admin.
Install-WindowsFeature -Name Web-Server, Web-CGI -IncludeManagementTools
Open your browser and confirm the default IIS home page loads.
HTTP://localhost HTTP://<hostname> HTTP://<hostname.domain.tld>
Note. Check our tutorial on how to configure, view and change IIS log location on Windows Server.
On Windows Desktop (10 or 11)
The base IIS installation with CGI on Windows Desktop uses a different command with different feature names. Run the command below in PowerShell as admin.
Enable-WindowsOptionalFeature -Online -FeatureName IIS-WebServerRole, IIS-CGI
Note. The same command works on Windows Server 2016 through 2022.
The IIS Manager is installed in C:\Windows\System32\inetsrv\InetMgr.exe, but it is not in the system PATH variable, meaning you can only run it by specifying the whole path. Run the command below to add the folder to the PATH environment variable.
[Environment]::SetEnvironmentVariable("PATH", $Env:PATH + ";C:\Windows\System32\inetsrv", [EnvironmentVariableTarget]::Machine)
The new system PATH will take effect once you restart the computer.
Open your browser and confirm the default IIS home page loads.
HTTP://localhost HTTP://<hostname> HTTP://<hostname.domain.tld>
Installing PHP Support in IIS
Assuming that IIS is now enabled and running, the next step is to install PHP support in IIS. This step is crucial for phpMyAdmin to run on your IIS web server.
Download and Extract PHP for IIS
- Download the latest PHP for Windows binaries from https://windows.php.net/download/. Ensure to download the “Non Thread Safe” variant. The newest version, as of this writing, is 8.2.7.
- Once downloaded, export the ZIP file to your preferred folder. For example, I’m extracting the contents to C:\PHP using PowerShell.
mkdir C:\PHP Expand-Archive -Path ~/Downloads/php-8.2.7-nts-Win32-vs16-x64.zip -DestinationPath C:\PHP
Feel free to do this using File Explorer if you prefer.
- Next, run this command to add C:\PHP to the system PATH:
[Environment]::SetEnvironmentVariable("PATH", $Env:PATH + ";C:\PHP", [EnvironmentVariableTarget]::Machine)
Create the PHP Initialization File
The PHP initialization filename is php.ini, located in the PHP installation folder, which, in this case, is C:.ini. This file does not exist by default, although the sample templates exist, namely php.ini-development and php.ini-production.
- In this example, we’ll create a copy of the production initialization file and name it php.ini:
# Change the working directory to the PHP installation folder Push-Location C:\PHP\ # Copy php.ini-production to php.ini Copy-Item .\php.ini-production .\php.ini
- Open the php.ini file in a text editor. In this example, I’m using Visual Studio Code.
code .\php.ini - Locate and uncomment the following lines by removing the semi-colon before each line:
extension_dir = "ext" extension=mysqli
Add Handler Mappings for PHP
Next, let’s configure the handler mapping for PHP in IIS. A handler mapping tells IIS how to handle a request path. In this example, we’re adding the handler mapping for “*.php*”.
- First, download and install the Visual C++ Redistributable.
- Open the IIS Manager by running this command:
inetmgr.exe
- Double-click the Handler Mappings feature.
- Click the Add Module Mapping in the Actions pane.
- Enter the following details in the Add Module Mapping window and click OK to save the module mapping.
- Request path: *.php*
- Module: FastCgiModule
- Executable: C:-cgi.exe
- Name: PHP
- Click Yes on the next prompt to confirm creating the PHP module mapping.
The PHP handler mapping has been created.
Add Default Document for PHP
Now let’s add a default document entry for PHP.
- Click the IIS computer name on the left pane and double-click the Default Document feature.
- Click Add under the Actions pane, type “index.php”, and click OK.
- Switch back to your PowerShell window and restart the IIS web server by running this command.
iisreset
Test PHP on IIS
To test whether IIS can now run PHP, let’s create a new file called phpinfo.php in the IIS root folder.
'<?php phpinfo(); ?>' | Out-File C:\inetpub\wwwroot\phpinfo.php -Encoding utf8
Open your browser and navigate to any of these URLs.
HTTP://localhost/phpinfo.php HTTP://<hostname>/phpinfo.php HTTP://<hostname.domain.tld>/phpinfo.php
The following webpage will be displayed, confirming that your PHP setup in IIS is working.
How to Install phpMyAdmin on IIS?
Now that IIS and PHP are configured, it’s time to install phpMyAdmin.
Download and Extract phpMyAdmin
- Navigate to the phpMyAdmin downloads page using your browser.
- Download the latest “all-languages” variant. As of this writing, the newest version is phpMyAdmin-5.2.1-all-languages.zip.
- Once downloaded, extract the contents to the IIS root (c:).
Expand-Archive -Path ~/Downloads/phpMyAdmin-5.2.1-all-languages.zip -DestinationPath c:\inetpub\wwwroot\
- After the extraction, a new subfolder, phpMyAdmin-<version>-all-languages, is created. Let’s rename it to phpMyAdmin.
Rename-Item C:\inetpub\wwwroot\phpMyAdmin-5.2.1-all-languages phpMyAdmin
Create a Configuration File
phpMyAdmin requires a configuration file to function properly. Instead of creating this file manually, we can use the built-in phpMyAdmin setup page to generate it.
- Visit the phpMyAdmin setup page at http://localhost/phpmyadmin/setup/.
- Click New server.
- Enter the Server hostname. Valid values are:
- Hostname — “localhost”, “db1.theitbros.com”.
- IP v4 address.
- IP v6 address.
- dot “.” — for named pipes on Windows.
- empty “” — server is disabled.
Click Apply.
Note. If your MySQL server uses a non-default port, you must specify it here.
- The server is now listed in the configuration. Click Download to download the configuration file.
- Copy the downloaded config.inc.php file to the C:\inetpub\wwroot\phpMyAdmin folder.
Create a MySQL User for phpMyAdmin
At this point, phpMyAdmin is installed. To access it, navigate to HTTP://localhost/phpmyadmin. If you log in using the root account, you will get the following error message.
This error happens because the root account can only log on to the local host, and that’s probably best for security. The logical step is to create another MySQL user account that we can use with phpMyAdmin.
- Log in to your MySQL server and open the MySQL command line client. You can do so from the Start menu.
Or from the command line.& "C:\Program Files\MySQL\MySQL Server 8.0\bin\mysql.exe" -u root -p
If on Linux, run sudo mysql -u root -p.
- Run the below command to create a new MySQL account that can log in from anywhere. Replace USERNAME and PASSWORD accordingly.
CREATE USER 'USERNAME' @'%' IDENTIFIED WITH mysql_native_password BY 'PASSWORD';
Next, give it full access to the MySQL server. Replace USERNAME as needed.
GRANT ALL PRIVILEGES ON *.* TO 'USERNAME' @'%' WITH GRANT OPTION;
- Quit the MySQL client by running quit.
- Reconnect to MySQL using the new account to test if it works. Replace USERNAME as needed.
& "C:\Program Files\MySQL\MySQL Server 8.0\bin\mysql.exe" -u USERNAME -p
Log in to phpMyAdmin
Now that we have the dedicated MySQL admin account, let’s test it with phpMyAdmin.
- On the computer where you installed phpMyAdmin, navigate to HTTP://localhost/phpMyAdmin.
- Log in using the new MySQL user account you created.
- You can now manage your MySQL server using the phpMyAdmin interface. You can:
- Access, import, and export databases.
- Create and remove users.
- Run SQL queries.
- And more.
That’s it! You’ve successfully installed phpMyAdmin on IIS in Windows.
Conclusion
Installing phpMyAdmin on IIS in Windows 11 or Windows Server 2022 is a straightforward process that simplifies MySQL database management. Following the step-by-step instructions outlined in this blog post, you can set up phpMyAdmin and access it through your web browser.
The installation process involves meeting prerequisites, such as installing IIS and configuring PHP correctly. After downloading and extracting the latest version of phpMyAdmin, necessary configuration changes are made in the PHP configuration file, including enabling extensions and setting up authentication.
Once installed, phpMyAdmin provides a user-friendly interface for managing databases, executing SQL queries, and importing/exporting data. It significantly enhances database management workflow and productivity for developers, system administrators, and database managers.
Enjoy the benefits of streamlined database management and leverage the powerful features of phpMyAdmin to administer and manipulate your MySQL databases efficiently.