How to Install PhpMyAdmin on Ubuntu 22.04?

PhpMyAdmin is a crucial ingredient for website developers which provides the database management while developing any websites. Due to its robust behavior, this utility is available on Windows and well-known Linux distributions. In this post, the installation method of the PhpMyAdmin is briefly explained on Ubuntu 22.04. The content for this post is given below:

Let’s begin with this guide.

Prerequisite: Install MySQL Server and PHP

Before going to the installation of PhpMyAdmin, you must have to install a mySQL server in your Ubuntu operating system, which will be covered. The procedure for installing the mysql server is discussed below:

Step 1: Update the Packages

Top 10 Linux Distros

First, open the terminal, update the packages and make sure all packages are updated. If not, upgrade it using the below commands:

$ sudo apt update

As all packages are up to date.

Step 2: Install MySQL Server

To install the MySQL server, execute the following command:

$ sudo apt install mysql-server

Once installed, login to the MySQL shell via the following command:

$ sudo mysql

Let’s move to the next step.

Step 3: Change the Default Root Password

After installing the mysql server change the default password with your desired password and exit from mysql. For this, the following query will be used:

> ALTER USER 'root'@'localhost' IDENTIFIED with mysql_native_password by 'itslinuxfoss'; > exit

After that, restart the mySQL server by executing the below command:

$ sudo service mysql restart

Step 4: Secure the MySQL

Now, secure install the mysql in ubuntu; this will ask for the password which you have set in the above query:

$ sudo mysql

Warning:

After entering the password, the access will be denied because the password you have set is for the root user, so you must log in as root user:

Solution:

To login as a root user execute the following command and enter the password:

$ mysql -u root -p

Now, secure the mysql server using the below command:

$ mysql_secure_installation

This command will ask for different security options, which can be answered with “y” or “n” depending upon your requirement. In our case, we have answered with “y” for better security.

Step 5: Install PHP

Finally, install php for PhpMyAdmin, using the following command:

$ sudo apt install php

Here you go! All the prerequisite steps are performed.

How to Install PhpMyAdmin on Ubuntu 22.04?

You can head over to the installation of PhpMyAdmin once all the prerequisites are managed i.e., MySQL server is installed and configured, and PHP is installed. To install PhpMyAdmin, execute the below command and follow the guide:

$ sudo apt install phpmyadmin

After executing the above command, it will display options for the web server. Choose the apache2 web server by pressing “spacebar” from the keyboard and press Enter:

Now the final screen will ask you for the configuration of the database. In our scenario, there is no requirement for it because we have already set up the database. Navigate to the “No” option and press Enter:

All done. PhpMyAdmin has been installed.

How to Use PhpMyAdmin on Ubuntu 22.04?

If all the installation and configuration steps are carried out error-free, then you can launch PhpMyAdmin from the browser using the following link:

localhost/phpmyadmin

Note: Instead of using the word “localhost”, the users can use the IP address associated with their localhost.

Doing so, the following interface will appear, where you have to enter the username and password to log in:

After login, the user can access PhpMyAdmin as shown in the below image:

This is the method to install PhpMyAdmin on Ubuntu.

How to Remove PhpMyAdmin From Ubuntu 22.04?

If you want to remove the PhpMyAdmin (to vacate some space or to reconfigure PhpMyAdmin), you can use the below-mentioned command:

$ sudo apt remove phpmyadmin

To uninstall PhpMyAdmin with all dependencies and libraries use the following command:

$ sudo apt purge phpmyadmin

That’s all from this post.

Conclusion

To install PhpMyAdmin, you need to install a mysql server executing the “sudo apt install mysql-server” and PHP as well. Then, install the PhpMyAdmin using the “sudo apt install phpmyadmin” command. PhpMyAdmin gives a graphical user interface to control the databases associated with the websites/PHP source code. This post has briefly explained the method to install PhpMyAdmin on Ubuntu 22.04.