---
title: "Step-by-Step Tutorial to Install phpMyAdmin Securely on Linux"
description: "Discover how to securely install phpMyAdmin on Linux with our concise guide. Learn essential steps for a safe and efficient setup, tailored for Linux users."
canonical: "https://adamtheautomator.com/install-phpmyadmin/"
---

# Step-by-Step Tutorial to Install phpMyAdmin Securely on Linux

> Discover how to securely install phpMyAdmin on Linux with our concise guide. Learn essential steps for a safe and efficient setup, tailored for Linux users.

Source: https://adamtheautomator.com/install-phpmyadmin/

---

ATA Learning

Tap to hide

[

ATA Learning

](/)

*   [Home](/)
*   [Tutorials](/tutorials/)
*   [Instructors](/author/)
*   [Advertising](/advertising/)
*   [Recommended Resources](/resources/)
*   [About Adam](/about-adam/)

Search for:  

*   [](https://twitter.com/adbertram)
*   [](https://github.com/Adam-the-Automator)
*   [](https://www.linkedin.com/company/adam-the-automator-llc)
*   [](/feed/)

![Step-by-Step Tutorial to Install phpMyAdmin Securely on Linux](https://adamtheautomator.com/wp-content/uploads/2021/12/install-phpmyadmin.jpg)

# Step-by-Step Tutorial to Install phpMyAdmin Securely on Linux

[![](https://secure.gravatar.com/avatar/1d5db60939ece32121195cb29b4c258de024b41175af140952313871de84ecde?s=192&d=mm&r=g)Loeber Deryk](https://adamtheautomator.com/author/loeber-deryk/)22 November 20236 min. read

Categories: [IT Ops](/category/it-ops/)

Tags:[Command Line](/tag/command-line/)[Linux](/tag/linux/)[phpMyAdmin](/tag/phpmyadmin/)

Table of Contents

*   [Prerequisites for Installing phpMyAdmin](#prerequisites-for-installing-phpmyadmin)
*   [Steps to Install phpMyAdmin on Ubuntu](#steps-to-install-phpmyadmin-on-ubuntu)
*   [Configuring Apache2 for phpMyAdmin Installation](#configuring-apache2-for-phpmyadmin-installation)
*   [Securing phpMyAdmin with a Strong Password](#securing-phpmyadmin-with-a-strong-password)
*   [Verifying phpMyAdmin Configuration Files](#verifying-phpmyadmin-configuration-files)
*   [Enabling mbstring Extension for phpMyAdmin](#enabling-mbstring-extension-for-phpmyadmin)
*   [Restarting Webserver for phpMyAdmin](#restarting-webserver-for-phpmyadmin)
*   [Best Practices for Creating a Secure phpMyAdmin User Account](#best-practices-for-creating-a-secure-phpmyadmin-user-account)
*   [Step 1: Accessing MySQL Shell](#step-1-accessing-mysql-shell)
*   [Step 2: Creating a New MySQL User](#step-2-creating-a-new-mysql-user)
*   [Granting Full Privileges to Your New User](#granting-full-privileges-to-your-new-user)
*   [Accessing the phpMyAdmin Interface](#accessing-the-phpmyadmin-interface)
*   [Enhancing phpMyAdmin Security with Password Protection](#enhancing-phpmyadmin-security-with-password-protection)
*   [Step 1: Configuring Apache for .htaccess Use](#step-1-configuring-apache-for-htaccess-use)
*   [Step 2: Restarting Apache to Apply Changes](#step-2-restarting-apache-to-apply-changes)
*   [Step 3: Creating the .htaccess File for phpMyAdmin](#step-3-creating-the-htaccess-file-for-phpmyadmin)
*   [Setting Up Additional Authentication for phpMyAdmin](#setting-up-additional-authentication-for-phpmyadmin)
*   [Accessing phpMyAdmin with Enhanced Security](#accessing-phpmyadmin-with-enhanced-security)
*   [Wrapping Up: phpMyAdmin Installation and Security](#wrapping-up-phpmyadmin-installation-and-security)

If you’re looking to streamline your MySQL server management on Linux, why not consider a GUI-based approach? The command-line can be daunting, but a front-end tool like [phpMyAdmin](https://www.phpmyadmin.net) can make things a lot easier. In this guide, we’ll cover the steps to install phpMyAdmin, a must-have for any sysadmin or developer. Let’s dive in!

phpMyAdmin, with its web-based interface, simplifies MySQL management. This tutorial will show you how to install and configure phpMyAdmin, making database management a breeze.

By the end of this tutorial, you’ll say goodbye to accidental database mishaps! Let’s learn how to safeguard your databases and, ultimately, your job.

## Prerequisites for Installing phpMyAdmin

Before starting, ensure you have the following:

*   An Ubuntu Server 18.04 or newer.

Related:[How to Install Ubuntu 20.04 \[Step-by-Step\]](https://adamtheautomator.com/install-ubuntu/)

*   Root or sudo access on your server. Check out how to enable these in [Ubuntu](https://www.ubuntu18.com/ubuntu-enable-root/).
*   Your server should have the LAMP (Linux, Apache, MySQL, PHP) stack. For installation guidance, refer to [this guide](https://www.linode.com/docs/guides/how-to-install-a-lamp-stack-on-ubuntu-18-04/).
*   A separate computer with an SSH client like [Putty](https://www.putty.org/), [Bitvise](https://www.bitvise.com/ssh-client-download), or the [Chrome SSH Extension](https://chrome.google.com/webstore/detail/secure-shell-app/pnhechapfaindjhompbnflcldabbghjo?hl=en). This tutorial uses the default SSH client in Windows 10 (`ssh.exe`).

Related:[How to Set up the SSH Google Chrome Extension](https://adamtheautomator.com/ssh-chrome-extension/)

## Steps to Install phpMyAdmin on Ubuntu

There are various methods to install phpMyAdmin, but the simplest and most common is using the Advanced Package Tool (APT). Follow these steps for a smooth installation.

1\. Connect to your Ubuntu server using an SSH client.

```powershell
ssh username@server_name_or_IP
```

2\. Begin by updating your server’s package repository to ensure you’re getting the latest software versions.

```bash
sudo apt update -y
```

> Depending on your server’s internet connection and system load, this update might take a few minutes.

![winscp command line updating package repository sources cache](https://adamtheautomator.com/wp-content/uploads/2021/12/image-47.png)

Updating the package repository sources cache

3\. After updating, install the `phpmyadmin` package along with its dependencies `php-mbstring` and `php-gettext`.

```bash
sudo apt install phpmyadmin php-mbstring php-gettext -y
```

4\. During the phpMyAdmin installation process, you’ll encounter a series of prompts to configure phpMyAdmin properly.

## Configuring Apache2 for phpMyAdmin Installation

On the webserver configuration screen, use the arrow keys to navigate. Highlight **apache2** and press SPACE to select it. An asterisk `[*]` will appear next to apache2, indicating it’s selected. Then, press Enter.

![install phpmyadmin - Selecting apache2 as the webserver](https://adamtheautomator.com/wp-content/uploads/2021/12/image-48.png)

Selecting apache2 as the webserver during the phpMyAdmin installation

5\. The installer will then prompt for the phpMyAdmin database setup. Make sure **<Yes>** is selected and press **Enter** to proceed.

![Confirming the phpMyAdmin database installation](https://adamtheautomator.com/wp-content/uploads/2021/12/image-49.png)

Confirming the phpMyAdmin database installation

## Securing phpMyAdmin with a Strong Password

6\. The phpMyAdmin installation process automatically creates a MySQL user named _phpMyAdmin_. Enter a strong password for this new account at the prompt, and press Enter.

![install phpmyadmin - Assigning a new phpMyAdmin password](https://adamtheautomator.com/wp-content/uploads/2021/12/image-50.png)

Assigning a new phpMyAdmin password

7\. Confirm your phpMyAdmin password by re-entering it on the **Password confirmation** prompt and press **Enter**. Wait for the installation and configuration to complete.

![Confirming the new password](https://adamtheautomator.com/wp-content/uploads/2021/12/image-51.png)

Confirming the new phpMyAdmin password

## Verifying phpMyAdmin Configuration Files

8\. After installing phpMyAdmin, confirm the existence of the Apache configuration file for phpMyAdmin by running the following command.

```bash
ls /etc/apache2/conf-enabled/
```

> _The phpmyadmin.conf file contains vital phpMyAdmin settings, like installation location and the database server configuration. Usually, there’s no need for manual edits to this file._

![Listing the /etc/apache2/conf-enabled directory contents](https://adamtheautomator.com/wp-content/uploads/2021/12/image-52.png)

Checking the /etc/apache2/conf-enabled directory for phpMyAdmin configuration

## Enabling mbstring Extension for phpMyAdmin

9\. To optimize phpMyAdmin’s functionality, enable the [mbstring](https://docs.phpmyadmin.net/en/latest/glossary.html#term-mbstring) PHP extension with the command below.

```bash
sudo phpenmod mbstring
```

## Restarting Webserver for phpMyAdmin

10\. Finally, [restart your webserver for the changes](https://adamtheautomator.com/ubuntu-systemctl/) to take effect. This step is crucial for making phpMyAdmin accessible.

```bash
sudo systemctl restart apache2
```

Related:[Controlling Systemd services with Ubuntu systemctl](https://adamtheautomator.com/ubuntu-systemctl/)

11\. Now, it’s crucial to verify the webserver’s status. This check confirms that the Apache server is running smoothly after the phpMyAdmin installation.

```bash
sudo systemctl status apache2
```

Look for a response indicating the Apache webserver service is **active (running)**, as shown in the screenshot below. This confirmation is a key step in successfully installing phpMyAdmin.

![install phpmyadmin - Checking the status of your web server](https://adamtheautomator.com/wp-content/uploads/2021/12/image-53.png)

Verifying the web server’s status after installing phpMyAdmin

## Best Practices for Creating a Secure phpMyAdmin User Account

As part of the phpMyAdmin setup, a default MySQL user named _phpmyadmin_ is created. However, this account is limited to accessing only the phpMyAdmin database and doesn’t have full administrative privileges.

To enhance security, it’s advisable to create a new, dedicated privileged account instead of using the default. This approach reduces the risk of attacks, as common usernames are often targeted.

Follow these steps to set up a secure, dedicated management account for phpMyAdmin:

## Step 1: Accessing MySQL Shell

Start by opening the MySQL shell. You can do this directly from the terminal using the following command:

```bash
sudo mysql
```

Alternatively, log in as the root user with this command:

```bash
sudo mysql -u root -p
```

## Step 2: Creating a New MySQL User

Once in the MySQL prompt, create a new user with custom credentials. Replace ‘ata’ and ‘pa$$word’ with your desired username and strong password. Here’s the command:

```sql
CREATE USER 'ata'@'localhost' IDENTIFIED BY 'pa$$word';
```

This step is vital for maintaining a secure phpMyAdmin setup.

![install phpmyadmin - Creating a new MySQL user account](https://adamtheautomator.com/wp-content/uploads/2021/12/image-54.png)

Creating a new MySQL user account during phpMyAdmin installation

## Granting Full Privileges to Your New User

3\. The next step in securing your phpMyAdmin installation is to grant full privileges to your newly created user. This is done using the `GRANT ALL PRIVILEGES` statement, which provides complete access to all databases. The `WITH GRANT OPTION` clause is particularly important as it allows this user to manage other user privileges.

```sql
GRANT ALL PRIVILEGES ON *.* TO 'ata'@'localhost' WITH GRANT OPTION;
```

![install phpmyadmin - Granting global privileges to a user](https://adamtheautomator.com/wp-content/uploads/2021/12/image-55.png)

Granting full privileges to the new user in phpMyAdmin

4\. Once you’ve assigned the necessary privileges, exit the MySQL shell to proceed with the phpMyAdmin setup.

```sql
exit
```

## Accessing the phpMyAdmin Interface

With the installation and user configuration complete, it’s time to access the phpMyAdmin web interface and verify the setup.

1\. Open your web browser and go to _http://your\_domain\_or\_IP/phpmyadmin_. Replace _your\_domain\_or\_IP_ with your server’s IP address or domain name.

2\. You’ll see the **Welcome to phpMyAdmin** login page. Enter the username and password for the account you just created.

![install phpmyadmin - Logging in to phpMyAdmin](https://adamtheautomator.com/wp-content/uploads/2021/12/image-56.png)

Logging into phpMyAdmin with the new user credentials

3\. Once logged in, the phpMyAdmin dashboard will be displayed, confirming a successful setup.

![The phpMyAdmin portal after installation](https://adamtheautomator.com/wp-content/uploads/2021/12/image-57.png)

The phpMyAdmin dashboard

4\. Test the new account’s privileges by navigating to the **Database** tab. Here, you can view all databases on the server and verify user privileges.

![install phpmyadmin - Checking the account privileges in phpMyAdmin](https://adamtheautomator.com/wp-content/uploads/2021/12/image-58.png)

Verifying the privileges of the new user account in phpMyAdmin

This completes the installation and setup of phpMyAdmin, ensuring you have a fully functional and secure database management interface on your Linux server.

![install phpmyadmin - Viewing the list of users with database privileges](https://adamtheautomator.com/wp-content/uploads/2021/12/image-59.png)

Viewing the list of users with database privileges in phpMyAdmin

## Enhancing phpMyAdmin Security with Password Protection

Given its widespread use, phpMyAdmin often becomes a target for unauthorized access attempts. It’s essential to implement additional security measures to protect your installation.

A highly effective way to secure phpMyAdmin is by using Apache’s .htaccess authentication and authorization features. This method adds an additional layer of security, restricting access to the phpMyAdmin interface.

Follow these steps to set up .htaccess protection for your phpMyAdmin installation:

## Step 1: Configuring Apache for .htaccess Use

Begin by editing the phpMyAdmin configuration file in Apache to allow .htaccess usage.

```bash
sudo nano /etc/apache2/conf-available/phpmyadmin.conf
```

2\. In the `<Directory /usr/share/phpmyadmin>` section of the file, add the `AllowOverride All` directive. This setting enables .htaccess files in the phpMyAdmin directory.

![install phpmyadmin - Adding the AllowOverride All directive](https://adamtheautomator.com/wp-content/uploads/2021/12/image-60.png)

Configuring the AllowOverride All directive in Apache for phpMyAdmin

3\. After adding the directive, save and exit the file. Remember to use spaces instead of tabs for indentation.

## Step 2: Restarting Apache to Apply Changes

4\. Restart the Apache server to ensure the new configuration is active.

```bash
sudo systemctl restart apache2
```

## Step 3: Creating the .htaccess File for phpMyAdmin

5\. The final step involves creating an .htaccess file in the phpMyAdmin directory. This file will manage access to phpMyAdmin.

```bash
sudo nano /usr/share/phpmyadmin/.htaccess
```

6\. Inside the .htaccess file, add the necessary directives to manage access. Once done, save and close the file.

By completing these steps, you’ll significantly increase the security of your phpMyAdmin installation on Linux, ensuring that only authorized users can access the management interface.

```bash
# Sets the authentication type to require entering the username and password.
AuthType Basic
# The message that the server displays on the credential prompt.
AuthName "Restricted Files"
# Specifies the file's location containing the valid users and passwords list.
AuthUserFile /etc/phpmyadmin/.htpasswd
# Allows the user who successfully authenticated to continue accessing phpMyAdmin.
Require valid-user
```

> _Not all web browsers display the [AuthName](https://httpd.apache.org/docs/2.4/mod/mod_authn_core.html#authname) directive value during authentication prompts._

![install phpmyadmin - Creating the .htaccess file](https://adamtheautomator.com/wp-content/uploads/2021/12/image-61.png)

Creating the .htaccess file for phpMyAdmin security

## Setting Up Additional Authentication for phpMyAdmin

7\. To further secure your phpMyAdmin installation, create an authentication file named _.htpasswd_. This file will store the usernames and encrypted passwords for authorized users.

```bash
sudo htpasswd -c /etc/phpmyadmin/.htpasswd username
```

Enter and re-confirm the password for the new user. A successful setup will enhance the security of your phpMyAdmin login process.

![install phpmyadmin - Creating a new authentication file](https://adamtheautomator.com/wp-content/uploads/2021/12/image-62.png)

Creating a new authentication file for phpMyAdmin

> _To add more users, use the command `sudo htpasswd /etc/phpmyadmin/.htpasswd additionaluser`, substituting `additionaluser` with the new username._

## Accessing phpMyAdmin with Enhanced Security

8\. With the additional security in place, navigate to `https://domain_name_or_IP/phpmyadmin` in your browser. Enter the username and password you established to access the login page.

![install phpmyadmin - The phpMyAdmin site prompting for username and password](https://adamtheautomator.com/wp-content/uploads/2021/12/image-63.png)

The phpMyAdmin site prompting for username and password

After successful authentication, you will be taken to the main phpMyAdmin login page.

![install phpmyadmin - The phpMyAdmin login page](https://adamtheautomator.com/wp-content/uploads/2021/12/image-64.png)

The phpMyAdmin login page after enhanced security setup

If the authentication fails, you’ll receive an **Unauthorized** response, indicating the need to recheck your credentials.

![install phpmyadmin - Failed phpMyAdmin site authorization](https://adamtheautomator.com/wp-content/uploads/2021/12/image-65.png)

Failed phpMyAdmin site authorization attempt

## Wrapping Up: phpMyAdmin Installation and Security

Congratulations on successfully installing and securing phpMyAdmin on Linux! You’ve now enhanced your database management capabilities, making MySQL management more accessible and secure.

Don’t stop here. Explore more advanced phpMyAdmin features and further security enhancements, such as implementing HTTPS and disabling root logins. Check out additional resources like [this guide](https://www.tecmint.com/secure-phpmyadmin-centos-ubuntu/) for more insights. Keep your phpMyAdmin environment secure and efficient!

Share this article

[Share on X](https://twitter.com/intent/tweet?url=https%3A%2F%2Fadamtheautomator.com%2Finstall-phpmyadmin%2F&text=Step-by-Step%20Tutorial%20to%20Install%20phpMyAdmin%20Securely%20on%20Linux)[Share on Facebook](https://www.facebook.com/sharer/sharer.php?u=https%3A%2F%2Fadamtheautomator.com%2Finstall-phpmyadmin%2F)[Share on LinkedIn](https://www.linkedin.com/sharing/share-offsite/?url=https%3A%2F%2Fadamtheautomator.com%2Finstall-phpmyadmin%2F)

## Related Posts

![](https://adamtheautomator.com/wp-content/uploads/2022/09/Practical-Linux-Unix-Tee-Commands-for-the-Linux-Admin.jpg)

### [Master Unix tee Commands for Real-World Linux Admin Tasks](/unix-tee/)

Simplify Linux output management and streamline your workflow with the “Unix tee” command. This tutorial guides you through its practical applications.

![](https://adamtheautomator.com/wp-content/uploads/2022/09/Useful-Linux-Dig-Examples-for-the-Network-Admin.jpg)

### [Linux Dig for Network Admins: Practical Guide with Examples](/linux-dig/)

Become a network troubleshooting expert! This comprehensive Linux Dig guide empowers you with essential DNS query commands for immediate results.

![](https://adamtheautomator.com/wp-content/uploads/2023/08/timedatectl.jpg)

### [Learning the timedatectl Command Though Examples](/timedatectl/)

Learn how to use the Linux timedatctl command-line tool to configure and set your systems time and date in this ATA Learning tutorial!

## Categories

*   [IT Ops](/category/it-ops/)
*   [Cloud](/category/cloud/)
*   [DevOps](/category/devops/)
*   [Home Ops](/category/home-ops/)
*   [Information Security](/category/infosec/)
*   [Software Development](/category/software-development/)

## Site

*   [Home](/)
*   [Tutorials](/tutorials/)
*   [Instructors](/author/)
*   [Advertising](/advertising/)
*   [Recommended Resources](/resources/)
*   [About Adam](/about-adam/)

Copyright 2026© ATA Learning | [Privacy Policy](/privacy/)
