phpMyAdmin is a web page that can run any SQL against your databases with a valid login. Scanners request /phpmyadmin/, /pma/, /mysql/ and thirty other paths on every server on the internet, every day, then try root with a password list. Left at its defaults it is the easiest way into a server that does not have it exposed for a reason. Here is how to run it safely, and the alternatives.
Do you need it exposed at all?
Plesk includes phpMyAdmin behind the panel's own login: Databases → phpMyAdmin opens it authenticated as the database user without a separate public URL. If you are on Plesk, that is the secure configuration already — do not install a second copy under a site. For a plain server, the alternatives below may mean you do not need a web-facing copy either.
1. Move it off the default path
If it is served by Apache or Nginx at /phpmyadmin, change the alias to something unguessable:
# Nginx
location /db-c7f2a9/ {
alias /usr/share/phpmyadmin/;
...
}# Apache: /etc/phpmyadmin/apache.conf or the site config
Alias /db-c7f2a9 /usr/share/phpmyadminThis removes you from the automated scans, which is most of the risk. It is not sufficient on its own.
2. Restrict by IP
location /db-c7f2a9/ {
allow 198.51.100.7; # office
allow 203.0.113.0/24; # VPN range
deny all;
...
}<Directory /usr/share/phpmyadmin>
Require ip 198.51.100.7 203.0.113.0/24
</Directory>If your address changes, use a VPN with a fixed exit (WireGuard on a VPS) and allow only that.
3. Add HTTP basic auth in front
A second password before phpMyAdmin's own login page appears:
sudo apt install apache2-utils -y
sudo htpasswd -c /etc/nginx/.pma_htpasswd adminlocation /db-c7f2a9/ {
auth_basic "Restricted";
auth_basic_user_file /etc/nginx/.pma_htpasswd;
...
}Brute-forcing now requires two independent credentials, and the phpMyAdmin login page never loads for anyone without the first.
4. HTTPS only
phpMyAdmin sends database passwords in the login form. Serve it only over TLS; in config.inc.php:
$cfg['ForceSSL'] = true;5. No root login
Root should not log in over the web at all. In config.inc.php:
$cfg['Servers'][$i]['AllowRoot'] = false;Give each site's database user access to its own database only (GRANT ALL ON example_db.* TO ...), and log in as that user. A compromised phpMyAdmin session then reaches one database, not all of them.
6. Keep it updated and configured
phpMyAdmin has had serious vulnerabilities; update it with the system packages, or if installed by hand, from the official site. Set a random blowfish_secret, disable the setup directory (delete it), and set $cfg['LoginCookieValidity'] to a short value (e.g. 900 seconds).
7. Fail2ban
Ban IPs that fail phpMyAdmin's login repeatedly. It logs to syslog with $cfg['AuthLog'] = 'syslog', and Fail2ban ships a phpmyadmin-syslog jail:
[phpmyadmin-syslog]
enabled = trueAlternatives that avoid the problem
- SSH tunnel + local client. Bind MySQL to
127.0.0.1(it should be anyway), then from your machine:ssh -L 3307:127.0.0.1:3306 user@serverand connect a desktop client (TablePlus, DBeaver, MySQL Workbench, Sequel Ace) tolocalhost:3307. Nothing is exposed on the web; authentication is your SSH key. - The command line.
mysqlon the server over SSH does everything phpMyAdmin does, without a web surface. - Adminer — a single-file alternative, easier to hide and to remove when not in use. Same restrictions apply.
Check your exposure
curl -sI https://example.com/phpmyadmin/ | head -1
curl -sI https://example.com/pma/ | head -1Anything other than 404 or 403 from the public internet is a page an attacker can reach. Plesk's built-in copy answers only inside the panel session; a copy someone installed into a site's httpdocs years ago is the one to look for.
On VPSPioneer shared plans, phpMyAdmin is available only through the Plesk login with the panel's 2FA in front; on a managed VPS we do not install a public copy at all, and set up the SSH tunnel method for whoever needs a GUI.