phpMyAdmin provides a web-based interface for managing MySQL/MariaDB databases — running queries, browsing tables, and managing users without needing the command line for every task.
Prerequisites
- Ubuntu or Debian VPS with Apache or Nginx, PHP, and MySQL/MariaDB already installed
- Root or sudo access
Step 1 — Install phpMyAdmin
sudo apt update
sudo apt install phpmyadmin -y
During installation you'll be prompted to select your web server (choose apache2 if using Apache) and set a phpMyAdmin database password.
Step 2 — Enable the PHP mbstring Extension (If Missing)
sudo phpenmod mbstring
sudo systemctl restart apache2
Step 3 — For Nginx Users: Create the Configuration Manually
Nginx doesn't auto-integrate phpMyAdmin like Apache does. Add a location block to your server block:
location /phpmyadmin {
root /usr/share/;
index index.php;
location ~ ^/phpmyadmin/(.+\.php)$ {
fastcgi_pass unix:/var/run/php/php8.3-fpm.sock;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
}
location ~* ^/phpmyadmin/(.+\.(jpg|jpeg|gif|css|png|js|ico|html|xml|txt))$ {
root /usr/share/;
}
}
sudo nginx -t && sudo systemctl reload nginx
Step 4 — Access phpMyAdmin
http://YOUR_SERVER_IP/phpmyadmin
Step 5 — Log In
Use your MySQL/MariaDB username and password — not the phpMyAdmin setup password, which is only for phpMyAdmin's own internal configuration storage.
Securing phpMyAdmin (Critical)
A publicly accessible phpMyAdmin login is a common attack target. At minimum:
- Restrict access to trusted IPs at the web server or firewall level
- Enable HTTPS via Let's Encrypt
- Never use the MySQL root account to log in through phpMyAdmin day-to-day
- Consider changing the default URL path
Restricting by IP in Nginx:
location /phpmyadmin {
allow YOUR_TRUSTED_IP;
deny all;
...
}
Common Errors
Blank page or 500 error — verify the PHP version referenced in the Nginx config (php8.3-fpm.sock) matches what's actually installed.
"mysqli extension is missing":
sudo apt install php-mysqli -y
sudo systemctl restart apache2
Best Practices
- Restrict access by IP whenever possible
- Always use HTTPS — never send database credentials over plain HTTP
- Keep phpMyAdmin updated, as it's a frequent target for known-vulnerability scanning
FAQ
Is phpMyAdmin required to manage MySQL?
No — it's a convenience tool; the mysql/mariadb command-line client provides full functionality without exposing a web-accessible attack surface.
Related Articles
- How to Install and Secure MySQL 8 on Ubuntu & Debian
- How to Install Let's Encrypt SSL with Certbot (Nginx & Apache)
- How to Configure UFW Firewall on a Linux VPS
