Install phpMyAdmin on Ubuntu 20.04 / 22.04 (How To)

Install phpMyAdmin on Ubuntu 20.04 / 22.04 (How To). In this article, we explore what phpMyAdmin is, its key features, and the benefits it brings to your work. We then  learn how to install phpMyAdmin on Ubuntu.

If you’re a web developer or a database administrator, you’ve probably heard of phpMyAdmin. But what exactly is it, and what it does? Well,  phpMyAdmin is the most popular tool for MySQL database management. Also, the most trusted database used for web applications and programs.

Well, let’s start with article Install phpMyAdmin on Ubuntu 20.04 / 22.04 (How To).

What is phpMyAdmin?

Primarily speaking, phpMyAdmin is a web based application that allows you to manage your MySQL or MariaDB databases through a web browser.

In addition, it provides a user friendly interface that lets you create and modify databases, tables, fields, and other database objects, run SQL queries, and manages users and permissions. Moreover, it manages indexes, users, and permissions in addition to running SQL queries and browsing data.

phpMyAdmin is written in PHP for web hosting services and runs on a web server, such as Apache or Nginx. Available for download from the official website. You can install it on a local server or a hosting account.

Key Features of phpMyAdmin

phpMyAdmin has a wide range of features that make it a powerful and versatile tool for database management. Some of the key features include:

  • Database management: With phpMyAdmin, you create, alter, and drop databases, tables, fields, and other database objects. You also import and export data from and to various formats, such as CSV, SQL, and XML.
  • SQL query editor: phpMyAdmin includes an SQL query editor that lets you run queries, view the results, and save them for later use. The editor also supports syntax highlighting, autocompletion, and query history.
  • User and permissions management: You create, alter, and delete users and manage their permissions with phpMyAdmin. You also set global privileges and assign specific privileges to individual users or groups. It manages all user level permissions.
  • Server administration: With phpMyAdmin, you view and manage server variables and status, optimize and repair tables, and monitor the server’s performance. What is more, you also set up replication and configure the server’s security.
  • Visualization and reporting: phpMyAdmin include several visualization and reporting tools that allow you to view and analyze your data in various formats, such as graphs, charts, and pivot tables.
  • Search Option: It is the most important feature of the tool. The Search option helps the user to have a look at the whole database system and the nodes connected to it when the user presses a key to search for the content.

Advantages of Using phpMyAdmin

  • Easy to use: One of the best advantages of phpMyAdmin is its user friendly interface. Even if you’re new to database management, you’ll be able to navigate through the tool easily. It comes with a visual representation of the database structure, which makes it easy to understand and use.
  • Supports multiple languages: phpMyAdmin supports multiple languages, which makes it accessible to users all over the world. This feature helps you work with a team of people who speak different languages.
  • Offers a range of features: In addition to the database management features, phpMyAdmin has several advanced features such as importing and exporting data, backing up and restoring databases and running SQL queries. These features make it a powerful tool for managing and maintaining databases.
  • Customizable: Another advantage of phpMyAdmin is that it is customizable to suit your specific needs. Simply choose which features you want to enable, and even add your custom plugins to increase efficiency.
  • Widely used: phpMyAdmin is a widely used tool, which means you’ll find a wealth of resources and support online. Whether you’re looking for tutorials, tips, or answers to specific questions, you’ll be able to find what you’re looking for.

Up next we learn how to Install phpMyAdmin on Ubuntu 20.04 / 22.04.

Install phpMyAdmin on Ubuntu 20.04 / 22.04 (How To)


  • Ubuntu 20.04 or Ubuntu 22.04 server installed and running.
  • A root user or a user with sudo privileges.

Step 1 - Install Apache and PHP

First, you need to install the Apache web server and PHP on your system. You install all of them by running the following command.

					apt install apache2 php libapache2-mod-php php-zip php-json php-mbstring php-mysql -y

Once all the packages are installed, you will need to start the Apache service and enable it to start at system reboot.

					systemctl start apache2
systemctl enable apache2

After installing Apache and PHP, you then proceed to install and configure the MariaDB database server.

Step 2 - Install and Configure MariaDB

phpMyAdmin is used to manage MariaDB and MySQL databases via a web browser. So, you will need to install the MariaDB server on your system. Please install it using the following command.

					apt install mariadb-server mariadb-client -y

After the successful installation, secure the MariaDB installation and set a root password with the following command.


Answer all the questions as shown below:

					Enter current password for root (enter for none): Press ENTER.
Switch to unix_socket authentication? Press N, then ENTER.
Change the root password? Press Y and set your password, then ENTER.
Remove anonymous users? Press Y, then ENTER.
Disallow root login remotely? Press Y, then ENTER.
Remove test database and access to it? Press Y, then ENTER.
Reload privilege tables now? Press Y, then ENTER.


After securing the MariaDB installation, log in to the MariaDB console as a root user.

					mysql -u root -p

Once you are logging in to the MariaDB console, create a database and user with the following command.

					CREATE DATABASE myadmin;
CREATE USER 'myadmin'@'localhost' IDENTIFIED BY 'password';


Next, grant all the privileges to myadmin database with the following command.

					GRANT ALL ON myadmin.* TO 'myadmin'@'localhost';

Then, flush the privileges and exit from the MariaDB console with the following command.


Step 3 - Install phpMyAdmin

Following, you need to download the latest version of phpMyAdmin from its official website. Also download it via the command line as shown below.


Once the download is complete, you will get the following output.

					phpMyAdmin-latest-a 100%[===================>] 11.90M 28.0MB/s in 0.4s

2023-01-15 14:16:06 (28.0 MB/s) - ‘phpMyAdmin-latest-all-languages.tar.gz’ saved [12474799/12474799]

Next, extract the downloaded file using the following command.

					tar -xzf phpMyAdmin-latest-all-languages.tar.gz

Then, move the extracted directory to the Apache web root directory.

					mv phpMyAdmin-5.2.0-all-languages /var/www/html/phpmyadmin

After that, create a temporary directory for phpMyAdmin.

					mkdir -p /var/www/html/phpmyadmin/tmp

Here, copy the phpMyAdmin sample configuration file.

					cp /var/www/html/phpmyadmin/ /var/www/html/phpmyadmin/

Following that, generate a secret password with the following command.

					openssl rand -base64 32

You will get the following output.


Next, edit the phpMyAdmin configuration file.

					nano /var/www/html/phpmyadmin/

Define your secret and temp directory as shown below:

					$cfg[‘blowfish_secret’] = ‘kbzA5GBuXpgmfQj28FCxuFq4UeBZV0UW0M0ngE39cc4=‘;

$cfg['TempDir'] = '/var/www/html/phpmyadmin/tmp';

Save and close the file when you are done. Then, change the ownership of the phpMyAdmin directory.

					chown -R www-data:www-data /var/www/html/phpmyadmin

At this point, phpMyAdmin is downloaded and configured. You can now proceed to configure the Apache web server to serve phpMyAdmin.

Step 4 - Create an Apache Virtual Host for phpMyAdmin

Now, you need to create an Apache virtual host configuration file to host phpMyAdmin using the Apache server. Create an Apache virtual host using the following command.

					nano /etc/apache2/conf-available/phpmyadmin.conf

Add the followig configuration.

					Alias /phpmyadmin /var/www/html/phpmyadmin

<Directory /var/www/html/phpmyadmin/>
AddDefaultCharset UTF-8
<IfModule mod_authz_core.c>
Require all granted

<Directory /var/www/html/phpmyadmin/setup/>
<IfModule mod_authz_core.c>
Require all granted


Save and close the file then activate the Apache virtual host using the following command.

					a2enconf phpmyadmin.conf

Next, restart the Apache service to apply the configuration changes.

					systemctl restart apache2

Step 5 - Access phpMyAdmin Web UI

At this point, the phpMyAdmin is installed and configured on your server. Access it using the URL http://your_server_ip/phpmyadmin. You should see the phpMyAdmin login page.

Provide your database username, password and click on the Login button. You should see the phpMyAdmin dashboard on the following page.

Thank you for reading Install phpMyAdmin on Ubuntu 20.04 / 22.04 (How To). We will conclude this article blog. 

Install phpMyAdmin on Ubuntu 20.04 / 22.04 (How To) Conclusion

In this post, we explained how to install phpMyAdmin with Apache on Ubuntu 20.04 / 22.04. Finally,  you can now create, delete and manage databases and run any query via the phpMyAdmin web interface.

Overall, phpMyAdmin is a powerful and versatile tool essential for managing and maintaining a MySQL database. The tool is used by several developers and database managers worldwide due to its friendly user interface and wide range of customizable features. Whether you’re a beginner or an experienced user, you’ll find that phpMyAdmin is an invaluable tool for managing and maintaining your databases.

Explore more of our Apache content in our blog by navigating over here

Avatar for Hitesh Jethva
Hitesh Jethva

I am a fan of open source technology and have more than 10 years of experience working with Linux and Open Source technologies. I am one of the Linux technical writers for Cloud Infrastructure Services.

0 0 votes
Article Rating
Notify of
Inline Feedbacks
View all comments
Would love your thoughts, please comment.x