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:
- An Ubuntu Linux VPS with SSH access.
- A web server (Apache2 or Nginx). 👉 How to Set Up Web Servers on Ubuntu
- MariaDB or MySQL. 👉 How to Install & Secure MariaDB on Ubuntu
- PHP and required extensions installed (
php-fpm,php-mysql).
Step 1: Install phpMyAdmin Package
- Connect to your VPS via SSH and update your package list:
sudo apt update - Install phpMyAdmin along with required PHP extensions:
sudo apt install -y phpmyadmin php-mbstring php-zip php-gd php-json php-curl - During the installation wizard prompts:
- Web Server Selection: If you are using Apache2, press Space to select
apache2and 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).
- Web Server Selection: If you are using Apache2, press Space to select
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:
- 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 - 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:
- Log in to the MariaDB command line:
sudo mysql -u root -p - Create a new admin user with a strong password:
CREATE USER 'pma_admin'@'localhost' IDENTIFIED BY 'YourSuperSecretPassword123!'; - Grant full administrative privileges to the new user:
GRANT ALL PRIVILEGES ON *.* TO 'pma_admin'@'localhost' WITH GRANT OPTION; - 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:
- Open the Apache phpMyAdmin configuration file:
sudo nano /etc/phpmyadmin/apache.conf - Find the alias line near the top:
# Change Alias /phpmyadmin to your secret URL Alias /db-secret-panel-882 /usr/share/phpmyadmin - 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!
