Introduction

This guide is for users who are running a Debian 9 server with Apache, MySQL, and PHP.

The phpMyAdmin software tool is used for managing MySQL databases through a graphical interface. It can be configured to manage a local database, or a remote database (over the network). It replaces the awkward default command-line interface which can be used for database management.

This article assumes that you’ve already configured your database and LAMP stack, and you are ready to install phpMyAdmin on Debian 9.

During the configuration process, the installer will ask for a root user password for your existing database.

Prerequisites

  • LAMP (Linux, Apache, MySQL, PHP) stack installed and configured on the server
    • Linux is fulfilled with your Debian 9 installation
    • Apache is software for transmitting information over the internet
    • MySQL is a database application that we're managing with phpMyAdmin
    • PHP is a programming language for interpreting phpMyAdmin's commands
  • Access to a user account with root privileges (ability to use the sudo command)
    • In Gnome, you can access the console from Applications > System Tools > Terminal
    • In KDE, you can access the console from K > System > Terminal (Konsole)

Tools/Software

  • A Debian 9 operating system, configured for LAMP
    • This should include a database, which already has a root user
    • MySQL is often used, but alternates like MariaDB can also be used
  • Command prompt with root access

Tutorial

Step 1: Refresh the Latest Version of the Software Packages

The software package for phpMyAdmin is part of the default software repositories, but you’ll want to make sure you’re getting the latest version. Refresh the repositories with the following command:

Sudo apt-get update && apt-get upgrade

Do not skip this step! Some of the older versions of phpMyAdmin had security flaws, and could allow unauthorized users to access your database.

Install phpMyAdmin

To install phpMyAdmin, type the following:

Sudo apt-get install phpmyadmin

The system will run through several automated steps to install phpMyAdmin. Once it finishes, you’ll be offered a configuration screen.

Step 2: Configure phpMyAdmin

The first option will ask you to choose which web server to reconfigure automatically – make sure apache2 is selected, and click OK.

Next, it will give you some information about advanced configuration. If you’re an advanced user, please refer to the documentation – in this guide we are focusing on a guided installation. ClickOK.

On the next screen, it will ask if you want to configure the database for phpmyadmin with dbconfig-common – this is setting up a default configuration for you. Click Yes.

Next, it will ask you to input a password for phpMyAdmin. Enter a password (and make a note of it), or leave the space blank to auto-generate a password.  This will be the password to access phpMyAdmin.

Finally, the installer will request your root password for the database. Enter it, and click OK.

You can confirm that phpMyAdmin is installed and contains a configuration file by opening a file browser and navigating to:

/etc/apache2/conf-enabled/phpmyadmin.conf

If you are an advanced user and you have any custom configurations to add, you can edit this file with your favorite text editor.

Step 3: Secure phpMyAdmin by Changing the Alias

The Alias is a line in the configuration file that specifies the web address to access the application. Since many hackers and bots target the default configuration, it’s a good idea to change the alias.

Open the phpmyadmin configuration file by typing in the console:

Sudo vim /etc/apache2/conf-enabled/phpmyadmin.conf

Look for a line that says:

Alias /phpmyadmin /usr/share/phpmyadmin

Flag this line as a comment by adding a # sign:

# Alias /phpmyadmin /usr/share/phpmyadmin

Then, type a new line below it and change the alias:

Alias /phpmyadmin /usr/share/MySecretLogin

Save the file and exit.

NOTE

You can change MySecretLogin to any alias you’d like.

Step 4: Refresh the Apache Web Services

Enter the following in your console:

Sudo service apache2 restart

Step 5: Accessing phpMyAdmin

Open a web browser, and use the IP address of the system you are working on, followed by the Alias you set in Step 3. You can use https://whatismyipaddress.com/ or https://www.whatismyip.com/ to find your IP address.

The web address for phpMyAdmin will look like:

http://IP_ADDRESS/MySecretLogin

The web page should display a login screen for phpMyAdmin. Enter the username and password for your database user, and you’ll be able to manage the database utilities from the graphical interface.

Conclusion

Now you have phpMyAdmin installed and configured on your Debian 9 server.

The phpMyAdmin software package takes a lot of the pain out of managing a database via command-line, and most database administrators consider it a staple of their installation.