Do You Need phpMyAdmin?
phpMyAdmin is a web interface for MySQL and MariaDB. Many administrators do without it: an SSH tunnel with a desktop database client, or the mysql command-line client over SSH, does the same work without a web application that can be attacked. If you want a browser interface anyway, install it so that the internet cannot reach it.
Prerequisites
You need Nginx, PHP-FPM, and MySQL or MariaDB on the server. PHP is covered in how to install PHP on Ubuntu and MySQL in how to install MySQL on Ubuntu.
Install the Package on Ubuntu and Debian
sudo apt update
sudo apt install phpmyadminRead the list of new packages before you confirm. If apt wants to add Apache, cancel and run the command again with --no-install-recommends. When the installer asks which web server to configure, select none, because Nginx is set up by hand below. It may offer to create its own configuration database with dbconfig-common; accepting is fine. The files land in /usr/share/phpmyadmin.
AlmaLinux, Rocky Linux, or the Project's Release
On AlmaLinux and Rocky Linux the base repositories have no phpMyAdmin package; the EPEL repository has one, with its files in /usr/share/phpMyAdmin and its configuration in /etc/phpMyAdmin/. That package also adds /etc/nginx/default.d/phpMyAdmin.conf, which publishes /phpMyAdmin on the default site; move that file out of the folder before you reload Nginx. On this family, PHP-FPM listens on /run/php-fpm/www.sock, and Nginx has no sites-available folder or snippets: put the site in /etc/nginx/conf.d/ and replace the include line below with include fastcgi_ plus a fastcgi_ line.
To use the project's own release instead, download the archive and its .asc signature from the project's website and check it with gpg --verify against the project's signing key before you unpack it. Unpack it into /usr/share/phpmyadmin, copy config.sample.inc.php to config.inc.php, and set a random blowfish_ of exactly 32 bytes in it.
Option 1: Reachable Only Through an SSH Tunnel
This is the safest setup. Create /etc/nginx/sites-available/phpmyadmin with a site that listens on loopback only:
server {
listen 127.0.0.1:8081;
root /usr/share/phpmyadmin;
index index.php;
location / {
try_files $uri $uri/ =404;
}
location ~ ^/(setup|libraries|templates)/ {
deny all;
}
location ~ \.php$ {
include snippets/fastcgi-php.conf;
fastcgi_pass unix:/run/php/php8.3-fpm.sock;
}
}The deny block must come before the PHP block: Nginx uses the first matching regular expression. Use the socket name of your PHP version (ls /run/php/), for example 8.3 on Ubuntu 24.04 and 8.5 on Ubuntu 26.04. Enable the site, test, and reload:
sudo ln -s /etc/nginx/sites-available/phpmyadmin /etc/nginx/sites-enabled/
sudo nginx -t && sudo systemctl reload nginxFrom your computer, open the tunnel with ssh -L 8081:127.0.0.1:8081 user@your_ and browse to http://127.0.0.1:8081. SSH encrypts the traffic, and no port is open to anyone. SSH port forwarding explains the syntax.
Option 2: HTTPS Limited to Your IP
If you need it in a browser without a tunnel, serve it on its own subdomain over HTTPS only, with a certificate from Certbot for Nginx, and add two layers inside the server block:
allow 203.0.113.10;
deny all;
auth_basic "Restricted";
auth_basic_user_file /etc/nginx/.htpasswd;Replace the address with your own public IP. Create the password file with sudo htpasswd -c /etc/nginx/.htpasswd admin, which asks for the password; the tool comes in the apache2-utils package on Debian and Ubuntu and in httpd-tools on AlmaLinux and Rocky Linux. Do not serve it over plain HTTP at all.
Log In with a Dedicated Account
Ubuntu's MySQL root account logs in through the system's root user and has no password, so it cannot log in here, and should not. Create an account for your own administrative work in sudo mysql:
CREATE USER 'dbadmin'@'localhost' IDENTIFIED BY 'STRONG_PASSWORD';
GRANT ALL PRIVILEGES ON app.* TO 'dbadmin'@'localhost';Limit it to the databases you manage. How to list users in MySQL shows how to review accounts.
Keep It Updated
The package updates with the system; see sudo apt update. A release installed by hand does not, so watch the project's security announcements and replace the folder when a fix comes out. If you stop using phpMyAdmin, remove it rather than leave it installed.
Troubleshooting
- 502 Bad Gateway: the
fastcgi_socket does not match the running PHP-FPM version.pass - 403 Forbidden: your address is not in the
allowlist, orindexis missing. - Cannot log in: the account does not exist for
localhostor has a wrong password.
Updated:
Linux VPS with Full Root Access
MUVCloud cloud servers run on KVM with Enterprise NVMe SSD storage and full root access, in Turkey, the Netherlands, and the USA.
More Guides
No Limits on Service or Support
You are not on your own as your projects grow. Our support engineers are ready 24/7, on several channels, whenever you need them.

- 100% customer satisfaction goal
- Our own hardware
- 24/7 ticket and email support
- 4 countries with locations