Article Background
Back to Knowledgebase

How to Install and Secure phpMyAdmin on an Ubuntu VPS

VPS
Cubes Support
July 20, 2026

phpMyAdmin is a free, open-source web-based management tool for MySQL and MariaDB databases. Instead of executing raw SQL queries in the command line, phpMyAdmin provides a graphical user interface in your browser to import .sql database dumps, manage tables, inspect logs, and manage database users easily.

This step-by-step guide will walk you through installing phpMyAdmin on a Cubes Hosting Ubuntu VPS, configuring it for Apache or Nginx, creating a dedicated administrative user, and hardening its URL security.


Prerequisites

Before starting, ensure you have installed:


Step 1: Install phpMyAdmin Package

  1. Connect to your VPS via SSH and update your package list:
    sudo apt update
    
  2. Install phpMyAdmin along with required PHP extensions:
    sudo apt install -y phpmyadmin php-mbstring php-zip php-gd php-json php-curl
    
  3. During the installation wizard prompts:
    • Web Server Selection: If you are using Apache2, press Space to select apache2 and press Enter. If you are using Nginx, press Tab and Enter to skip this screen.
    • Configure database for phpmyadmin with dbconfig-common: Select Yes and press Enter.
    • Application Password: Enter a secure password for phpMyAdmin's internal database user (or press Enter to let it auto-generate).

Step 2: Configure Web Server Integration

For Apache2 Users:

Apache configures phpMyAdmin automatically during installation. Enable the PHP mbstring extension and restart Apache:

sudo phpenmod mbstring
sudo systemctl restart apache2

(You can now access phpMyAdmin by visiting http://YOUR_SERVER_IP/phpmyadmin).


For Nginx Users:

Nginx requires linking phpMyAdmin's installation directory into your web root:

  1. Create a symbolic link pointing to phpMyAdmin:
    # Replace /var/www/example.com/html with your actual Nginx web root directory
    sudo ln -s /usr/share/phpmyadmin /var/www/example.com/html/phpmyadmin
    
  2. Reload Nginx:
    sudo systemctl reload nginx
    

(Access phpMyAdmin at http://YOUR_DOMAIN_OR_IP/phpmyadmin).


Step 3: Create a Dedicated phpMyAdmin Admin User

In modern MariaDB/MySQL installations, the root database account uses unix_socket authentication, which intentionally prevents root logins through web forms like phpMyAdmin.

Create a dedicated administrative user for phpMyAdmin:

  1. Log in to the MariaDB command line:
    sudo mysql -u root -p
    
  2. Create a new admin user with a strong password:
    CREATE USER 'pma_admin'@'localhost' IDENTIFIED BY 'YourSuperSecretPassword123!';
    
  3. Grant full administrative privileges to the new user:
    GRANT ALL PRIVILEGES ON *.* TO 'pma_admin'@'localhost' WITH GRANT OPTION;
    
  4. Apply the new privileges and exit:
    FLUSH PRIVILEGES;
    EXIT;
    

You can now log in to the phpMyAdmin web panel using pma_admin and your secure password!


Step 4: Security Hardening (Hide the phpMyAdmin URL)

Because automated bots scan /phpmyadmin on every server IP to attempt brute-force attacks, renaming your phpMyAdmin URL path adds an immediate layer of security through obscurity.

On Nginx:

Rename your symbolic link to a secret custom URL path:

sudo mv /var/www/example.com/html/phpmyadmin /var/www/example.com/html/db-secret-panel-882

On Apache:

  1. Open the Apache phpMyAdmin configuration file:
    sudo nano /etc/phpmyadmin/apache.conf
    
  2. Find the alias line near the top:
    # Change Alias /phpmyadmin to your secret URL
    Alias /db-secret-panel-882 /usr/share/phpmyadmin
    
  3. Save the file and restart Apache:
    sudo systemctl restart apache2
    

Now, your phpMyAdmin web interface is accessible only via your secret URL (http://YOUR_SERVER_IP/db-secret-panel-882), rendering automated bot scanners completely harmless!


Conclusion

phpMyAdmin makes managing databases, importing .sql files, and managing tables fast and visual on your Cubes Hosting Ubuntu VPS. Configure your dedicated admin user, secure your URL alias, and enjoy easy web-based database management!

Special Offer

Ready to Start Your Server?

Get 10% OFF your first month on any server with promo code CUBES10 at checkout!

24/7 Assistance

Need Help With Your Server?

Already a Cubes Hosting customer and couldn't find your answer? Our dedicated support team is available 24/7.