This post shows students and new users the steps to install and configure phpMyAdmin on Ubuntu Linux with Apache support. phpMyAdmin is an open source web tool that allows users to easily manage MySQL or MariaDB databases from their favorite web browsers.

Traditionally, users typically connect to the console of a database server and run queries and commands to manage databases, user permissions, and other tasks. However, for those who are not comfortable using the command line interface to manage databases, the phpMyAdmin web interface is a great alternative.

With phpMyAdmin, you can manage MySQL databases, user accounts and privileges, execute SQL statements, import and export data in a variety of data formats, and much more.

To start installing phpMyAdmin, continue with the steps below:

How to install Apache on Ubuntu Linux

phpMyAdmin needs a web server to work, and Apache HTTP Server is a great open source server that you can use with phpMyAdmin.

To install Apache on the Ubuntu server, run the following commands.

sudo apt update
sudo apt install apache2

After installing Apache, the following commands can be used to stop, start and enable Apache services always start with the server starting.

sudo systemctl stop apache2.service
sudo systemctl start apache2.service
sudo systemctl enable apache2.service

To find out if Apache is installed and running, just open your web browser and type in the IP or hostname of the server.

If you see a page similar to the one above, Apache is installed and working.

How to install MariaDB on Ubuntu Linux

phpMyAdmin is a tool for managing database servers. For our database server, we will install MariaDB. phpMyAdmin should also work with the MySQL database server, but we will install it here.

To install MariaDB, run the following commands.

sudo apt install mariadb-server
sudo apt install mariadb-client

After installing MariaDB, the following commands can be used to stop, start and enable The MariaDB service always starts when the server starts.

sudo systemctl stop mariadb.service
sudo systemctl start mariadb.service
sudo systemctl enable mariadb.service

After that, run the following commands to secure the MariaDB server by creating a root password, not allowing remote root access, removing anonymity, and more.

sudo mysql_secure_installation

When prompted, answer the questions below by following the guide.

If you've just installed MariaDB, and haven't set the root password yet, you should just press enter here.

Enter current password for root (enter for none): PRESS ENTER

Switch to unix_socket authentication [Y/n] n

Change the root password? [Y/n] n

Remove anonymous users? [Y/n] y

Disallow root login remotely? [Y/n] y

Remove test database and access to it? [Y/n] y

Reload privilege tables now? [Y/n] y

All done!

To verify that MariaDB is installed and running, run the following commands.

How to create a phpMyAdmin user for MariaDB

The latest MariaDB servers come with the root user configured to use the auth_socket default authentication method.

the auth_socket The plugin authenticates users connecting from the local host through the Unix socket file. This means that you cannot authenticate as root by providing a password.

This can cause problems with some applications that need to connect to the database via root. To fix this, you will need to change the default authentication mechanism from auth_socket for mysql_native_password.

However, doing so could present security risks, as root users should not be used to remotely connect to the database. A recommended method is to create a dedicated user to remotely connect to your database servers.

Since you don’t want to connect to the MariaDB database server from phpMyAdmin as root user, you should probably create a separate account instead of connecting with root.

Run the following commands to log into the MariaDB server.

sudo mysql -u root -p

Then run the SQL commands below to create a new user for phpMyAdmin to use to connect to the database.

CREATE USER 'phpmyadmin'@'localhost' IDENTIFIED BY 'very_strong_password_here';

Then give the user full access to manage the database server.

GRANT ALL PRIVILEGES ON *.* TO 'phpmyadmin'@'localhost' WITH GRANT OPTION;

How to install PHP on Ubuntu Linux

PHP is required for phpMyAdmin. The PHP packages are added to the Ubuntu repositories. However, the versions in the repositories may not be the latest. If you need to install the latest versions, you will need to add a third-party PPA repository.

In a third-party repository with the latest versions of PHP, run the following commands.

sudo apt-get install software-properties-common
sudo add-apt-repository ppa:ondrej/php

At the time of writing, the latest version of PHP 8.0.

sudo apt update

Then run the following commands to install PHP 8.0 and related modules.

sudo apt install php8.0 php8.0-common php8.0-mysql php8.0-gmp php8.0-curl php8.0-intl php8.0-mbstring php8.0-xmlrpc php8.0-gd php8.0-xml php8.0-cli php8.0-zip

How to install phpMyAdmin on Ubuntu Linux

Now that Apache and PHP are installed, the final step is to install phpMyAdmin and configure. To do that, run the following commands

sudo apt install phpmyadmin

When prompted to choose your web server, select apache2 and continue.

+------------------------+ Configuring phpmyadmin +-------------------------+
 | Please choose the web server that should be automatically configured to   |
 | run phpMyAdmin.                                                           |  
 | Web server to reconfigure automatically:                                  |
 |                                                                           |
 |    [*] apache2                                                            |
 |    [ ] lighttpd                                                           |                                                 | 
 |                                 <ok>                                                                            |

When prompted again to allow debconfig-common to install a database and configure, select Yes and press ENTER.

Then enter and confirm a password.

 +------------------------+ Configuring phpmyadmin +-------------------------+
 |                                                                           |
 | The phpmyadmin package must have a database installed and configured      |
 | before it can be used.  This can be optionally handled with               |
 | dbconfig-common.                                                          |
 |                                                                           |
 | If you are an advanced database administrator and know that you want to   |
 | perform this configuration manually, or if your database has already      |
 | been installed and configured, you should refuse this option.  Details    |
 | on what needs to be done should most likely be provided in                |
 | /usr/share/doc/phpmyadmin.                                                |
 |                                                                           |
 | Otherwise, you should probably choose this option.                        |
 |                                                                           |
 | Configure database for phpmyadmin with dbconfig-common?                   |
 |                                                                           |
 |                  <Yes>                  <No>                              |
 |                                                                           |

After installing phpMyAdmin, open your web browser and search for the server’s hostname or IP address followed by / phpmyadmin.

Login with the account you created earlier for phpMyAdmin.

That is all!

If you followed the steps above and it didn’t work, try this solution:

sudo nano /etc/apache2/apache2.conf

Then add the following line to the end of the file.

Include /etc/phpmyadmin/apache.conf

Then restart apache

sudo systemctl restart apache2


In this tutorial we have seen how to install phpMyAdmin on Ubuntu Linux. If you find any errors above or have something to add, use the comment form below.

Write A Comment