Introduction

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.

Are you ready to learn how to install phpMyAdmin on Debian 9?

installation of phpmyadmin on debian 9

Prerequisites

  • LAMP (Linux, Apache, MySQL, PHP) stack installed and configured on the server
  • Access to a user account with root privileges (ability to use the sudo command)
  • 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

Install phpMyAdmin on Debian 9

Refresh Latest Version of 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, enter:

sudo apt-get install phpmyadmin

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

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. Click OK.

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.

To confirm that phpMyAdmin is installed and contains a configuration, open a file browser and navigate 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.

Securing phpMyAdmin

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 entering:

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.

Refresh Apache Web Services

To refresh Apache web services, use the command:

sudo service apache2 restart

Accessing phpMyAdmin

Open a web browser, and use the IP address of the system you are working on, followed by the Alias you set earlier.

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. Most database administrators consider it a staple of their installation.