Adminer
Install Adminer, a lightweight single-file database manager for MySQL, PostgreSQL, and SQLite
Adminer is a full-featured database management tool contained in a single PHP file. It's a lighter, faster alternative to phpMyAdmin. Supports MySQL, MariaDB, PostgreSQL, SQLite, and more.
Requirements
- PHP installed (7.4+)
- Nginx or Apache
- MySQL/MariaDB or PostgreSQL
Download Adminer
# Create a directory for the tool
sudo mkdir -p /var/www/adminer
# Download the latest single-file version
sudo wget -O /var/www/adminer/index.php https://github.com/vrana/adminer/releases/download/v4.8.1/adminer-4.8.1.php
# Set permissions
sudo chown -R www-data:www-data /var/www/adminerNginx configuration
Create a virtual host with IP restriction (never expose Adminer publicly):
sudo nano /etc/nginx/sites-available/adminerserver {
listen 8080;
server_name _; # or your server IP
root /var/www/adminer;
index index.php;
# Restrict to your IP only
allow YOUR_IP;
deny all;
location / {
try_files $uri $uri/ =404;
}
location ~ \.php$ {
include snippets/fastcgi-php.conf;
fastcgi_pass unix:/run/php/php8.2-fpm.sock;
}
}sudo ln -s /etc/nginx/sites-available/adminer /etc/nginx/sites-enabled/
sudo nginx -t && sudo systemctl reload nginxAccess at http://YOUR_SERVER_IP:8080
Always restrict Adminer access by IP. Never leave it publicly accessible, it exposes your entire database to brute force attacks.
Apache configuration
sudo nano /etc/apache2/sites-available/adminer.conf<VirtualHost *:8080>
DocumentRoot /var/www/adminer
<Directory /var/www/adminer>
Options -Indexes
AllowOverride None
Require ip YOUR_IP
</Directory>
</VirtualHost>sudo a2ensite adminer
sudo systemctl reload apache2Add a login password (extra protection)
Adminer can require a custom login plugin on top of database credentials. Create a login-password wrapper:
sudo nano /var/www/adminer/index.phpReplace the content with:
<?php
function adminer_object() {
class AdminerLogin extends Adminer {
function login($login, $password) {
return $password != ''; // Require non-empty password
}
}
return new AdminerLogin;
}
include './adminer-4.8.1.php';Or use the official login-password plugin:
sudo wget -O /var/www/adminer/plugins/login-password-less.php \
https://raw.githubusercontent.com/vrana/adminer/master/plugins/login-password-less.phpConnect to different database types
On the Adminer login page:
| System | Server | Credentials |
|---|---|---|
| MySQL/MariaDB | 127.0.0.1 | root or any DB user |
| PostgreSQL | 127.0.0.1:5432 | postgres or any role |
| SQLite | (leave blank) | path to .sqlite file |
Access via SSH tunnel (most secure)
Instead of exposing Adminer on any port, access it only through an SSH tunnel:
# On your local machine
ssh -L 8080:localhost:8080 user@your-server-ipThen open http://localhost:8080 in your browser. Port 8080 doesn't need to be open in the firewall at all.
Keep Adminer updated
LATEST=$(curl -s https://api.github.com/repos/vrana/adminer/releases/latest | grep tag_name | cut -d '"' -f 4 | tr -d 'v')
sudo wget -O /var/www/adminer/index.php \
"https://github.com/vrana/adminer/releases/download/v${LATEST}/adminer-${LATEST}.php"Remove when not needed
When you're done with maintenance, remove or disable Adminer:
sudo rm /var/www/adminer/index.php
# or disable the vhost
sudo rm /etc/nginx/sites-enabled/adminer
sudo systemctl reload nginx