How to Install PhpMyAdmin with LAMP on Ubuntu 18.04

PhpMyAdmin is a LAMP application particularly meant for MySQL server administration. It is an application built on PHP and can be easily accessed through the web browser. In short, it provides a user-friendly graphical interface for database administration.

In this article, I'll explain how to install PhpMyAdmin with LAMP on an Ubuntu 18.04 server.

Pre-requisites

Before installing PhpMyAdmin, you will need to install MySQL server and configure the password plugin properly for our installation. Assuming you have the root privileges, you can proceed with the pre-installation steps:

To install MySQL, run the following commands from a terminal prompt:

# apt install mysql-server

By default, MySQL uses local system account to log in as user root. This is done with a plugin “auth_socket". Please see the users password plugin status below:

root_password

As explained in the snapshot above, I've updated the root password plugin to "mysql_native_password" similar to the rest of the system users available and set the MySQL root password as required. This will prevent any MySQL connection problem and errors during the phpmyadmin installation.

Now, you can proceed with your PhpMyAdmin installation.

Installing PhpMyAdmin

PhpMyAdmin is available on our default Ubuntu 18.04 repository. Hence, we can install phpmyadmin by just running the command:

# apt-get install phpmyadmin

This installation proceeds with various installation stages as described below:

Stage 1: Installing Apache2

During this installation. it prompts you for the web-server installation, you need to choose the Apache2 option for setting up the web-server automatically with this installation.

phpmyadmin1_install.png

Stage 2: Configuring phpmyadmin database with dbconfig-common

In this stage, you will be prompted to configure a database for your PhpMyAdmin installation using dbconfig-common options. You can proceed by selecting "yes" to configure this database automatically.

configuring DB

Stage 3: Setting the MySQL password

In this step, you will need to set a MySQL password for phpmyadmin to connect to the database server.

Admin Pass

Once the password is confirmed, it will proceed and completes the installation successfully. In a nutshell, I would say, during this PHPMyAdmin installation, it installs a Web server, configures the database for phpmyadmin and updates the necessary configuration files, configures/install PHP and its required modules. Take a look at the complete list of newly added packages during the installation.

The following NEW packages will be installed:
apache2 apache2-bin apache2-data apache2-utils dbconfig-common dbconfig-mysql fontconfig-config fonts-dejavu-core javascript-common libapache2-mod-php7.2 libapr1 libaprutil1 libaprutil1-dbd-sqlite3
libaprutil1-ldap libfontconfig1 libgd3 libjbig0 libjpeg-turbo8 libjpeg8 libjs-jquery libjs-sphinxdoc libjs-underscore liblua5.2-0 libsodium23 libtiff5 libwebp6 libxpm4 libzip4 php php-bz2 php-common
php-curl php-gd php-mbstring php-mysql php-pear php-php-gettext php-phpseclib php-tcpdf php-xml php-zip php7.2 php7.2-bz2 php7.2-cli php7.2-common php7.2-curl php7.2-gd php7.2-json php7.2-mbstring
php7.2-mysql php7.2-opcache php7.2-readline php7.2-xml php7.2-zip phpmyadmin ssl-cert
0 upgraded, 56 newly installed, 0 to remove and 0 not upgraded.
Need to get 21.5 MB of archives.

Stage 4: Including the PhpMyAdmin configuration file to Apache 2

This is the final stage, where we need to include our PhpMyAdmin Apache configuration file to our main web server configuration. Please add this include line to the end of Apache 2 configuration file at /etc/apache2/apache2.conf and restart the service to make these changes effective.

Include /etc/phpmyadmin/apache.conf

Once it's done restart the service using this command below:

# systemctl restart apache2

That's all! we're done with our installation. Now you can access your PhpMyAdmin interface via browser at http://Server-IP/phpmyadmin/ with your root credentials.

phpmyadmin login

PhpMyAdmin software supports the server which is running either Windows or one of the several Linux distros. This provides you with an excellent solution for administering MySQL and MariaDB databases. You can easily manage any number of databases as needed. In addition, you can manage database tables, values and export/import more efficiently. I hope this article is useful and informative for you! I would really appreciate your valuable comments and suggestions for any further improvements.

Saheetha Shameer 12:05 am

About Saheetha Shameer

Self-motivated and dedicated Linux Administrator having 10 years of working experience on various web-hosting control panels and Unix distributions. I'm a quick learner and have a slight inclination towards following the current and emerging trends in the industry. I'm passionate about testing/reviewing new Linux applications and open source tools.

Author Archive Page

Have anything to say?

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

All comments are subject to moderation.

2 Comments

  1. Hi, (on ubuntu 18.04)
    I already got stuck at the very beginning logging in. No password would work. Which password did you use at:
    "mysql -u root -p"
    Thanks for the nice step by step guide anyway

    1. Thanks for the comment :). You are always Welcome!
      After the initial MySQL installation step "apt install mysql-server", I connected to the MySQL without any passwords. Just hit enter in the password prompt as we didn't set any passwords then.
      On the next step, I updated the root user password plugin status to "mysql_native_password" similar to the rest of the system users as mentioned in the snapshot and updated the root password to "[email protected]" with this following command in the MySQL prompt:
      UPDATE mysql.user SET authentication_string=PASSWORD('[email protected]'), plugin='mysql_native_password' WHERE User='root' AND Host='localhost';

      I hope this helps :).