How To Install phpMyAdmin on Ubuntu 22.04

In this guide, we will explain how to install phpMyAdmin on Ubuntu 22.04, allowing you to manage MySQL databases through a user-friendly web interface.

PhpMyAdmin is a free and open-source web-based tool written in PHP, used for managing MySQL and MariaDB databases. It provides a graphical interface for a variety of database operations, making it easier. phpMyAdmin simplifies the complex process of database management with its user-friendly web interface.

Prerequisites

It works on all Linux distributions.

Update && Upgrade the server

To update and upgrade the package lists from the repositories, run the following command

sudo apt update -y 
sudo apt upgrade -y

Install the necessary packages

To set up the essential packages for phpmyadmin installation.

sudo apt install apache2 mariadb-server php libapache2-mod-php php-mbstring php-zip php-gd php-json php-xml php-mysql

After Installation start and enable the service

MySQL Secure Installation

Run the MySQL secure installation

sudo mysql_secure_installation

Follow the prompts to set a root password and configure other security settings.

Install phpMyAdmin

To install phpmyadmin run the following command

sudo apt install phpmyadmin -y

During the installation, you can choose the webserver to configure for phpMyAdmin. Select apache2 and configure the database for phpMyAdmin.

The phpmyadmin packages must have a database installed and configured before it can be used. This can be optionally handled with dbconfig-common. Configure the database for phpmyadmin with dbconfig-common click on YES.

Please provide a password for phpmyadmin to register with the database server.

Now your phpmyadmin has been installed.

To create a Database and User

Login to the MySQL

sudo mysql -u root -p
  • Run these commands.

CREATE DATABASE mydatabase;
CREATE USER 'myuser'@'localhost' IDENTIFIED BY 'mypassword';
GRANT ALL PRIVILEGES ON mydatabase.* TO 'myuser'@'localhost';
FLUSH PRIVILEGES;
EXIT;

Configure phpMyAdmin

Edit the phpmyadmin configuration file /etc/phpmyadmin/config.inc.php to run these commands

sudo vi /etc/phpmyadmin/config.inc.php

After setting the user, password, and database to save the file and restart the service

sudo systemctl restart apache2

After setting everything up, you can access phpMyAdmin through your web browser. Here's how:

Log in using the credentials you set up

if you need to log in as an administrator, it is recommended to use the root user instead of the mysql user and password

Last updated