How To Phpmyadmin In Ubuntu

phpMyAdmin is an open-source MySQL and MariaDB administration tool that allows you to manage your databases, tables, users, and much more through a web-based interface. In this blog post, we will walk you through the process of installing and configuring phpMyAdmin on Ubuntu.

Prerequisites

To follow this tutorial, you will need:

  • An Ubuntu server
  • Apache, MySQL, and PHP installed (commonly referred to as a LAMP stack)
  • Access to a terminal or command line interface
  • Basic knowledge of Linux commands and MySQL

Step 1: Install phpMyAdmin

The first step is to install phpMyAdmin on your Ubuntu server. To do this, run the following command to update your package index and install the required packages:

sudo apt update
sudo apt install phpmyadmin php-mbstring php-zip php-gd php-json -y

During the installation process, you will be prompted to choose a web server. Select “apache2” by using the spacebar to mark it and then press Enter to continue.

You will also be asked if you want to use “dbconfig-common” to set up the phpMyAdmin database. Select “Yes” and enter a password for the phpMyAdmin user when prompted.

Step 2: Configure Apache

Next, you will need to configure Apache to work with phpMyAdmin. Create a symbolic link between the phpMyAdmin configuration file and the Apache configuration directory:

sudo ln -s /etc/phpmyadmin/apache.conf /etc/apache2/conf-available/phpmyadmin.conf

Now, enable the configuration file and restart Apache:

sudo a2enconf phpmyadmin
sudo systemctl reload apache2

Step 3: Secure phpMyAdmin

By default, phpMyAdmin can be accessed by anyone who knows the server’s IP address or domain name. To secure it, you can add an additional layer of authentication using Apache’s htpasswd utility. First, install the apache2-utils package:

sudo apt install apache2-utils

Create a new password file and add a user:

sudo htpasswd -c /etc/phpmyadmin/.htpasswd your_username

Enter a password for the user when prompted. Now, edit the phpMyAdmin Apache configuration file:

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

Add the following lines inside the <Directory> block, replacing “your_username” with the username you created earlier:

AuthType Basic
AuthName "Restricted Access"
AuthUserFile /etc/phpmyadmin/.htpasswd
Require valid-user
    

Save and exit the file, then reload Apache to apply the changes:

sudo systemctl reload apache2

Step 4: Access phpMyAdmin

You can now access phpMyAdmin by navigating to http://your_server_ip_or_domain/phpmyadmin in your web browser. You will be prompted to enter the username and password you created in Step 3, followed by the phpMyAdmin login screen. Log in using the “phpmyadmin” user and the password you set during the installation process.

Conclusion

You have successfully installed and configured phpMyAdmin on your Ubuntu server. You can now manage your MySQL databases, tables, and users through the user-friendly web interface. Make sure to keep your phpMyAdmin installation up-to-date and secure by regularly applying security patches and monitoring access logs.