How to Install phpMyAdmin On Ubuntu 24.04

Introduction

phpMyAdmin is a free web-based software that helps manage MySQL and MariaDB databases. It provides a user-friendly web interface, so you don't have to use complex command-line tools. This makes it easier for users to handle tasks like creating, modifying, or deleting databases, tables, and records.

This guide shows you how to install phpMyAdmin On Ubuntu 24.04 with LAMP stack.

Prerequisites

Before you begin, ensure you've:

Prepare User Accounts for phpMyAdmin

In this section, you'll prepare database users for phpMyAdmin, set up a sample database, and assign the necessary privileges using the MySQL command line interface.

  1. SSH to your Ubuntu 24.04 server and update your system's package information index.

    CONSOLE
    $ sudo apt update
    
  2. Log in to your MySQL database server as root. If you've installed a fresh copy of MySQL on Ubuntu 24, the root password is usually blank.

    CONSOLE
    $ sudo mysql -u root -p
    
  3. Create phpmyadmin'@'localhost user account. phpMyAdmin uses this account to perform necessary operations and maintain its configuration, often with limited privileges to ensure security. This dedicated account helps segregate application-specific tasks from other user operations. Replace your_secure_password with a strong password.

    MySQL
    mysql> CREATE USER 'phpmyadmin'@'localhost' IDENTIFIED BY 'your_secure_password';    
           GRANT ALL PRIVILEGES ON phpmyadmin.* TO 'phpmyadmin'@'localhost' WITH GRANT OPTION;
    

    Note:

    The above step is mandatory if you want to install phpMyAdmin On Ubuntu 24.04. Otherwise, you'll get an error that says:

    Your password does not satisfy the current policy requirements
    

    The above error occurs due to a bug in MySQL if you've installed the MySQL validate_password plugin. Even if you supply a password that meets the password policy, MySQL will still display the error. Another workaround is to uninstall the validate_password plugin temporary before installing phpMyAdmin and then install it back.

    MySQL
    mysql> UNINSTALL PLUGIN validate_password;
    
  4. Create a test e_commerce database. You'll access this database with a user account to ensure phpMyAdmin works as expected.

    MySQL
    mysql> CREATE DATABASE e_commerce; 
    
  5. Create a user account for accessing the e_commerce database. Replace your_secure_password with a strong password. Then assign the user full privileges to the e_commerce database.

    MySQL
    mysql> CREATE USER 'e_commerce_user'@'localhost' IDENTIFIED BY 'your_secure_password';    
           GRANT ALL PRIVILEGES ON e_commerce.* TO 'e_commerce_user'@'localhost' WITH GRANT OPTION;
    

    Note:

    While it's practically possible to create a MySQL user account that uses the phpMyAdmin interface to access all databases, it's highly discouraged for security reasons.

    This practice increases the risk of accidental deletions, data leaks, and potential security breaches.

    Instead, always adhere to the principle of least privilege to maintain a secure and well-managed database environment.

  6. Log out from the MySQL server.

    MySQL
    mysql> EXIT;
    

Install phpMyadmin

PhpMyadmin is maintained in the Ubuntu repositories. Follow the steps below to install the package using the APT command.

  1. Install the phpMyadmin package.

    CONSOLE
    $ sudo apt install phpmyadmin -y
    
  2. Select [ ] apache2 as the default web server for running phpMyadmin by pressing Tab + Enter.

  3. Press Enter to select Yes configure database for phpmyadmin with dbconfig-common.
  4. Enter the password you created for 'phpmyadmin'@'localhost' user account and press Tab, then Enter.
  5. Confirm the password on the next prompt and press Tab, then Enter.

Configure phpMyadmin with Apache

You should add a symbolic link to the /etc/apache2/conf-enabled/ directory for PhpMyadmin to work with Apache. Otherwise, if you try to access PhpMyadmin from the web browser, you will get the following error.

Not Found. The requested URL /phpMyadmin was not found on this server.

Create the symbolic link by following the steps below.

  1. Run the following ln command.

    CONSOLE
    $ sudo ln -s /etc/phpmyadmin/apache.conf /etc/apache2/conf-available/phpmyadmin.conf
    
  2. Enable the new configuration.

    CONSOLE
    $ sudo a2enconf phpmyadmin.conf
    
  3. Restart apache to load the new changes

    CONSOLE
    $ sudo service apache2 reload
    

Open PhpMyadmin on a Web Browser

After installing PhpMyadmin, you should ensure the package is working by following the steps below.

  1. Visit the following URL on a web browser such as chrome. Replace 192.168.0.1 with your server's public IP address.

    http://192.168.0.1/phpmyadmin
    

    If you installed phpMyadmin correctly, you should see a login page.

  2. Enter the e_commerce_user login details to access phpMyadmin.

    phpMyAdmin Login Page Ubuntu 24

  3. Manage the sample e_commerce database that you set up earlier.

    Manage MySQL Database Ubuntu 24

Troubleshoot phpMyadmin

If you encounter any errors when installing and configuring phpMyadmin, run the following commands to reconfigure phpMyadmin.

CONSOLE
$ sudo dpkg --configure -a

Conclusion

This guide shows you how to install phpMyAdmin on your Ubuntu 24.04 server. This user-friendly interface makes managing your MySQL databases much easier. With phpMyAdmin, you can create, modify, and delete databases, tables, and manage records effortlessly. You can also run SQL queries, import and export data, all through an intuitive web interface. This powerful tool simplifies database administration tasks and enhances your overall productivity.

  • Databases
  • Webservers
  • PHP
  • API
  • Python
  • VPS Guides
  • Network
  • AI
  • Node.js