Install phpMyAdmin with Apache on Ubuntu 20.04 - Step by Step Process ?

The native tool for access MySQL or MariaDB databases is the command-line.
With a few commands, you can access the database shell and perform a variety of tasks including viewing and creating databases and database users.
However, not everyone is a fan of the command-line, and this is where phpMyAdmin is beneficial.
Written in PHP, phpMyAdmin is a wonderful free and open-source tool that provides a front-end web interface to MySQL or MariaDB.
It allows users to log in and easily perform database management tasks such as managing databases, users, and permissions to mention a few.
Here at LinuxAPT, as part of our Server Management Services, we regularly help our Customers to perform related phpMyAdmin queries.
In this context, we shall look into the installation of phpMyAdmin on Ubuntu.

Common php package:
1. php-mbstring: A module for managing non-ASCII strings and convert strings to different encodings
2. php-zip: This extension supports uploading .zip files to phpMyAdmin
3. php-gd: Enables support for the GD Graphics Library
4. php-json: Provides PHP with support for JSON serialization
5. php-curl: Allows PHP to interact with different kinds of servers using different protocols
Run the following command to install these packages onto your system:

# sudo apt install phpmyadmin php-mbstring php-zip php-gd php-json php-curl



How to install phpMyAdmin with LAMP on Ubuntu 20.04 ?

PhpMyAdmin is PHP-driven and runs on the front-end. As such, ensure that you have installed LAMP on Ubuntu 20.04.
If you don't have it already, please head over to our guide on How to install LAMP.
Before proceeding with this task, ensure that you have configured a sudo user on your instance of Ubuntu 20.04.

1. Install PhpMyAdmin

i. To begin, access your terminal and update your package lists using the command provided:

$ sudo apt update

ii. The phpMyAdmin package is available on Ubuntu repositories, therefore, use the APT package manager to install it as follows:

$ sudo apt install phpmyadmin

Along the way, you will encounter some prompts.
First, choose your preferred web server.
Since you already have Apache installed, press the TAB key on the 'Apache' option and hit ENTER.
The phpMyAdmin package requires the installation and configuration of a database before use. Manual configuration is hectic and tedious.
Thankfully, the setup provides you an option to configure the database using the dbconfig-common which simplifies the configuration.
Select the 'Yes' option to tweak the phpMyAdmin database with the dbconfig-common package and hit ENTER.
Thereafter, provide the password for phpMyAdmin. And then confirm it.
The installation will then continue with the installation of the required packages, dependencies and PHP extensions that will be required by phpMyAdmin.
Once the installation is complete, a new database called phpmyadmin is created with the user phpmyadmin.
iii. If you want to feed your curiosity, proceed and access your database as shown.

$ sudo mysql -u root -p 

iv. To display the existing databases execute the MySQL command as follows.

> show databases;

Be sure to locate the phpmyadmin database.
v. Also, you can view the privileges assigned to the phpmyadmin user on the phpmyadmin database by invoking:

> show grants for phpmyadmin@localhost;


2. Verify successful installation of PhpMyAdmin

To ensure that the installation was successful, run the following command to confirm that the phpmyadmin.conf configuration file exists.

$ file /etc/apache2/conf-enabled/phpmyadmin.conf

The output should provide you with the full path to the configuration file and the symbolic link it points to.

3. Access PhpMyAdmin from a browser

The last step in the installation is to access the phpMyAdmin interface. On your browser, browse the address shown:

http://server-ip/phpmyadmin

The phpMyadmin login page comes to view where you can use the root credentials to log in.

NOTE:
If you encounter an error while logging into phpMyAdmin, follow the steps provided:
i. First, access the MySQL database as shown:

$ sudo mysql -u root -p

ii. Thereafter proceed and create a new database user :

> CREATE USER 'user'@'localhost' IDENTIFIED BY 'your-password;

iii. Next, accord all privileges to the user as shown

> GRANT ALL PRIVILEGES ON * . * TO 'user'@'localhost';

iv. Finally, flush privileges and exit the shell.

> FLUSH PRIVILEGES

Once logged in, you will be presented with the phpMyAdmin panel.

[Need urgent assistance in fixing phpmyadmin database related errors on Ubuntu Linux System ? We can help you. ]

This article covers how you can  seamlessly install phpMyAdmin on your Ubuntu Linux system.

Working with a database can sometimes be intimidating, but PhpMyAdmin can simplify tasks by providing a control panel to view or edit your MySQL or MariaDB database.

To Install phpMyAdmin on Ubuntu:
1. Update the apt package tool to ensure we are working with the latest and greatest.

$ apt update && upgrade

2. Install PhpMyAdmin and PHP extensions for managing non-ASCII string and necessary tools.

$ apt install phpmyadmin php-mbstring php-gettext

During this installation you’ll be asked for the web server selection, we will select Apache2 and select ENTER.
Here, you have the option for automatic setup or to create the database manually.
For us, we will do the automatic installation by pressing ENTER for yes.
3. At this setup, you'll be asked to set the PhpMyAdmin password.
Specifically for the PhpMyAdmin user, phpmyadmin,  you'll want to save this in a secure spot for later retrieval.
4. Enable PHP extension.

phpenmod mbstring

5. Restart the Apache service to recognize the changes made to the system.

# systemctl restart apache2

Related Posts