Installing phpMyAdmin on Ubuntu

phpMyAdmin is an open-source tool that simplifies managing MySQL or MariaDB databases via a web interface. Follow this detailed guide to set up phpMyAdmin on Ubuntu.

Prerequisites

  • Ubuntu installed on your machine.
  • Root or sudo privileges.
  • A working LAMP stack (Linux, Apache, MySQL/MariaDB, PHP).
sudo apt update && sudo apt upgrade -y
sudo apt install apache2 mysql-server php libapache2-mod-php php-mysql -y
sudo systemctl enable apache2
sudo systemctl start mysql

Step 1: Install phpMyAdmin

Install phpMyAdmin with the following command:

sudo apt install phpmyadmin -y

During installation:

  • Choose apache2 as the web server.
  • Select Yes to configure the database.
  • Set passwords for MySQL and phpMyAdmin as prompted.

Step 2: Enable Apache Configuration

Link phpMyAdmin to Apache:

sudo ln -s /usr/share/phpmyadmin /var/www/html/phpmyadmin

Restart Apache:

sudo systemctl restart apache2

Access phpMyAdmin at:

http://your-server-ip/phpmyadmin

Step 3: Secure phpMyAdmin

Enhance phpMyAdmin security:

Add .htaccess Authentication

sudo nano /usr/share/phpmyadmin/.htaccess

Add the following lines:

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

Set up a password file:

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

Step 4: Optional Remote Access

Modify Apache settings for remote access:

    Options FollowSymLinks
    DirectoryIndex index.php
    AllowOverride All
    Require all granted

Restart Apache:

sudo systemctl restart apache2

Step 5: Troubleshooting

Tip: Check Apache logs for errors using:

sudo tail -f /var/log/apache2/error.log

Ensure MySQL users have correct privileges:

sudo mysql -u root -p
GRANT ALL PRIVILEGES ON *.* TO 'your_user'@'localhost' IDENTIFIED BY 'your_password';
FLUSH PRIVILEGES;
EXIT;

Step 6: Maintain phpMyAdmin

Keep phpMyAdmin updated:

sudo apt update
sudo apt upgrade phpmyadmin -y

Conclusion

You’ve successfully installed and secured phpMyAdmin on Ubuntu. Access it at http://your-server-ip/phpmyadmin and follow best practices to ensure security.

For more information, visit the phpMyAdmin official website.

 

Related articles

Cognitive Computing Artificial Intelligence​

Cognitive Computing Artificial Intelligence​ In today’s rapidly evolving tech landscape, artificial intelligence and cognitive computing are often used interchangeably....

Configuring Backup for Azure App Services

Configuring Backup for Azure App Services Introduction Backing up your Azure App Services and associated databases is a crucial step...

Manage Azure Blob Lifecycles

🔄 Manage Azure Blob Lifecycles 🌟 Introduction to Azure blob storage lifecycle policy Azure Blob Storage provides a cost-effective way...

Kubernetes Diagnostics | Kubernetes Maintenance

Kubernetes Diagnostics Introduction Managing a Kubernetes cluster, especially in a dynamic environment like Azure Kubernetes Service (AKS), can quickly become...