MySQL MariaDB

Install PHP MyAdmin on Ubuntu 20.04

phpMyAdmin is a famous open-source tool designed to improve the management of MariaDB and MYSQL servers. It is written in the PHP language. As GUI apps and platforms are closer to users; therefore, accessing and managing databases on the command line is more difficult. But, Thanks to the phpMyAdmin web-based platform that enables us to use and manage databases using a graphical interface.

In this tutorial, we will discuss:

Prerequisite: Install Apache, MySQL, and PHP on Ubuntu 20.04

For the installation of phpMyAdmin, it is necessary to first install Apache server, MySQL, and PHP on Ubuntu 20.04. Otherwise, the user will get errors during the installation.

To install essential components for the phpMyAdmin installation, look at the provided instructions.

Step 1: Update System Packages

To update the system packages, first, launch the Ubuntu terminal through the “CTRL+ALT+T” key and update the package:

$ sudo apt update

Step 2: Install Apache

Install the Apache on Ubuntu 20.04 by executing the “apt install” command with sudo privileges:

$ sudo apt install apache2

Step 3: Allow Apache on Firewall

Next, enable Apache services on the Firewall using the given command:

$ sudo ufw allow in "Apache"

Check the status of the Apache service by utilizing the “ufw status” command:

$ sudo ufw status

Verify if the Apache is working on Ubuntu or not by navigating to “http://<your IP address>” in the browser:

http://192.168.113.130

You can see from the below output that Apache is running on the local host:

Step 4: Install MySQL Server

Next, install the MySQL server on Ubuntu 20.04 by utilizing the given command:

$ sudo apt install mysql-server -y

Step 5: Install PHP

For the PHP installation along with essential PHP libraries and packages, run the following command on the Ubuntu terminal:

$ sudo apt install php libapache2-mod-php php-mysql

Confirm the PHP installation and its version using the “php” command with the “-v” option:

$ php -v

From the given output, it can be observed that we have installed “PHP 7.4.3” on Ubuntu 20.04:

How to Install phpMyAdmin on Ubuntu 20.04?

After fulfilling the prerequisites, install the phpMyAdmin database on Ubuntu 20.04 with the help of the offered instructions.

Step 1: Install phpMyAdmin

Install the phpMyAdmin on Ubuntu 20.04 using the “apt install” command with the “sudo” privileges:

$ sudo apt install phpmyadmin

Upon doing so, the “Package configuration” wizard will appear on the screen. Select the “apache2” option and hit the “Enter” key:

Again, hit the “Enter” key to proceed further:

Configure the phpMyAdmin database on Ubuntu 20.04 by selecting the “OK” option:

After that, you will be prompted to set a password for accessing the database. Enter the password and press the “Enter” key:

Again, retype the password and press “Enter”:

Here, you can see we have completely installed the phpMyAdmin database:

Step 2: Access phpMyAdmin on Ubuntu Terminal

Next, access the phpMyAdmin database on the terminal through the given command. Here, the “-u” option is used to specify a username, and “-p” is utilized to add the password. By default, the username of the database is set as root:

$ sudo mysql -u root -p

Enter the password that you have set during phpMyAdmin installation:

To view all databases linked with MySQL database, utilize the below command:

> show databases;

Step 3: Grant LocalHost Privileges to phpMyAdmin Database

Next, grant all the local host privileges to the phpMyAdmin database:

> GRANT ALL PRIVILEGES ON 'phpmyadmin'.* To 'phpmyadmin '@' localhost';

To exit the command line, first, flush all privileges and utilize the “Exit” command:

> FLUSH PRIVILEGES;
> Exit;

Step 4: Access phpMyAdmin on the Local Host

Now, try to access the phpMyAdmin database on the localhost by navigating to the “http://<ip-address>/phpmyadmin” URL in the browser:

http://192.168.113.130/phpmyadmin

At this point, you may get the following error:

Step 5: Open Apache Configuration File

To resolve the stated error, open the Apache configuration file by processing the following command on the terminal:

$ sudo -H gedit /etc/apache2/apache2.conf

Step 6: Include phpMyAdmin Configurations

After that, add the phpMyAdmin configuration in the file at the end, and press the “CTRL+S” key to save changes:

Include /etc/phpmyadmin/apache2.conf

Step 7: Restart Apache

Now, restart the Apache services through the mentioned command:

$ /etc/init.d/apache2 restart

While doing so, the “Authentication Required” wizard will appear on the screen. Add your password and hit the “Authenticate” button:

Again, try to access the phpMyAdmin on the local host by visiting the “http://<ip-address>/phpmyadmin” URL on the browser:

http://192.168.113.130/phpmyadmin

The below output shows that we have successfully resolved the error and accessed the phpMyAdmin database on the local host:

Here you go! You have learned the method for installing phpMyAdmin on Ubuntu 20.04.

Conclusion

To install the phpMyAdmin on Ubuntu 20.04, first, you are required to install “MySQL”, “Apache” and “PHP” on the system. After that, install the phpMyAdmin on Ubuntu 20.04 by utilizing the “$ sudo apt install phpmyadmin” command. Next, grant all localhost privileges to phpMyAdmin and access it on the browser by navigating to the “http://<ip-address>/phpmyadmin” URL. This article has demonstrated how to install phpMyAdmin on Ubuntu 20.04.

About the author

Rafia Zafar

I am graduated in computer science. I am a junior technical author here and passionate about Programming and learning new technologies. I have worked in JAVA, HTML 5, CSS3, Bootstrap, and PHP.