For our Blog Visitor only Get Additional 3 Month Free + 10% OFF on TriAnnual Plan YSBLOG10
Grab the Deal

How to Use phpMyAdmin on Linux Server in 2026? Expert Guide

phpMyAdmin on a Linux server is a web based tool that lets you manage MySQL/MariaDB databases through a browser. To use it, install phpMyAdmin on your LAMP/LEMP stack, secure access (HTTPS, IP allowlist, strong auth), then log in with a MySQL user to create databases, run SQL, and perform backups and imports.

You’ll learn exactly how to use phpMyAdmin on a Linux server from installation on Ubuntu/Debian and RHEL based systems to hardening, login, everyday database tasks, and troubleshooting.

Whether you run a VPS or a dedicated server, this step by step tutorial keeps your database management simple and secure.


What is phpMyAdmin and When Should You Use it?

phpMyAdmin is a PHP application that provides a graphical interface for MySQL and MariaDB. It’s perfect when you want fast database administration without memorizing SQL syntax. Use it to create databases and users, import/export data, optimize tables, run queries, and check performance all from your browser.

Prerequisites

Before you use phpMyAdmin on a Linux server, ensure:

  • Linux distro: Ubuntu/Debian or RHEL/CentOS/Alma/Rocky
  • Web server: Apache (LAMP) or Nginx (LEMP)
  • PHP with extensions: mysqli, json, mbstring, zip, xml, gd, curl
  • MySQL or MariaDB server running and reachable
  • Root or sudo access to install packages and edit configs
  • HTTPS configured (Let’s Encrypt is fine) and firewall in place

Install phpMyAdmin on Linux (Ubuntu/Debian & RHEL/Alma/Rocky)

We’ll cover both families. Replace versions and PHP-FPM socket paths if needed.

Ubuntu/Debian (Apache or Nginx)

sudo apt update
sudo apt install apache2 mariadb-server php php-mbstring php-zip php-xml php-gd php-curl php-mysql
sudo apt install phpmyadmin

During install, choose your web server (select Apache if prompted). If not prompted or using Nginx, you’ll configure it manually.

RHEL/CentOS/AlmaLinux/Rocky

phpMyAdmin is available via EPEL or Remi on RHEL-based systems. Enable repositories and install:

# Enable EPEL (if not enabled)
sudo dnf install epel-release -y

# Install LAMP or LEMP prerequisites
sudo dnf install httpd mariadb-server php php-mbstring php-zip php-xml php-gd php-curl php-mysqlnd -y

# Install phpMyAdmin
sudo dnf install phpMyAdmin -y

# Start services
sudo systemctl enable --now httpd mariadb

Apache Configuration (custom URL and access control)

On many distros, phpMyAdmin installs to /usr/share/phpmyadmin. Create a clean alias like /dbadmin and restrict access.

sudo nano /etc/apache2/conf-available/phpmyadmin.conf    # Ubuntu/Debian
# or
sudo nano /etc/httpd/conf.d/phpMyAdmin.conf              # RHEL-based
Alias /dbadmin /usr/share/phpmyadmin
<Directory /usr/share/phpmyadmin>
    Options SymLinksIfOwnerMatch
    DirectoryIndex index.php
    AllowOverride All

    # Allow only specific IPs (example: admin office + localhost)
    Require ip 203.0.113.0/24
    Require ip 127.0.0.1
</Directory>

For Apache on Ubuntu/Debian, enable and reload:

sudo a2enconf phpmyadmin
sudo systemctl reload apache2

On RHEL-based systems, simply reload:

sudo systemctl reload httpd

Optional: HTTP Basic Auth for Apache

sudo htpasswd -c /etc/phpmyadmin/.htpasswd adminuser
# Enter a strong password
<Directory /usr/share/phpmyadmin>
    AuthType Basic
    AuthName "Restricted phpMyAdmin"
    AuthUserFile /etc/phpmyadmin/.htpasswd
    Require valid-user
</Directory>

Nginx Configuration (reverse proxy to PHP-FPM)

Add a location block to your server block. Adjust PHP-FPM socket path and PHP version as needed.

sudo nano /etc/nginx/sites-available/your-site.conf
location /dbadmin {
    alias /usr/share/phpmyadmin;
    index index.php;
    try_files $uri $uri/ /index.php;
    auth_basic "Restricted phpMyAdmin";
    auth_basic_user_file /etc/nginx/.pma;
}

location ~ \.php$ {
    include snippets/fastcgi-php.conf;          # Debian/Ubuntu
    fastcgi_pass unix:/run/php/php8.2-fpm.sock; # Adjust version/socket
}
# Create Basic Auth file:
sudo sh -c "printf 'adminuser:' && openssl passwd -apr1 &>/etc/nginx/.pma" 
# Type password and press Enter
sudo nginx -t && sudo systemctl reload nginx

Secure phpMyAdmin (Must-Do Checklist)

  • Serve only over HTTPS (use Let’s Encrypt).
  • Change the default path to a non-obvious alias (e.g., /dbadmin).
  • Restrict IPs using Apache Require/Nginx allowlists.
  • Add HTTP Basic Auth in front of phpMyAdmin.
  • Set a Blowfish secret for cookies in config.inc.php.
  • Apply strong MySQL user passwords and minimal privileges.
  • Use a firewall (UFW/firewalld) to allow only management IPs.
sudo nano /etc/phpmyadmin/config.inc.php
<?php
$cfg['blowfish_secret'] = 'use-32-characters-or-more-R4nd0m_Str1ng!'; // change me
$cfg['TempDir'] = '/var/lib/phpmyadmin/tmp';
$cfg['UploadDir'] = 'upload';
$cfg['SaveDir'] = 'save';

Restrict via UFW (Ubuntu/Debian) to your office IP for HTTPS only:

sudo ufw allow from 203.0.113.10 to any port 443 proto tcp
sudo ufw deny 80/tcp

Create a MySQL Admin User (First-Time Login)

Use a dedicated MySQL user for phpMyAdmin. Avoid logging in as root over the web UI.

sudo mysql -u root

-- Inside MySQL/MariaDB:
CREATE USER 'dbadmin'@'localhost' IDENTIFIED BY 'Super_Strong_Passw0rd!';
GRANT ALL PRIVILEGES ON *.* TO 'dbadmin'@'localhost' WITH GRANT OPTION;
FLUSH PRIVILEGES;
EXIT;

Now visit https://your-domain.com/dbadmin, pass Basic Auth if enabled, and log in with the MySQL user you created.


How to Use phpMyAdmin: Common Tasks

Create Databases and Users

  • Click Databases > Create database > Choose collation (e.g., utf8mb4_general_ci).
  • Go to User accounts > Add user account > Set host to localhost or a specific host.
  • Grant only required privileges (e.g., SELECT, INSERT, UPDATE for an app user).

Import and Export Data

  • Export: Select database > Export > Quick or Custom > SQL or compressed format.
  • Import: Select database > Import > Choose file > Set format > Execute.
  • For large files, increase PHP/Nginx upload limits (see troubleshooting).

Run SQL Queries and Optimize Tables

  • SQL tab: run queries, EXPLAIN statements, or schema changes safely.
  • Structure > Check all > Optimize table to defragment and update statistics.
  • Repair tables if MyISAM errors occur (use with caution, prefer InnoDB).

Backups with phpMyAdmin vs CLI

  • phpMyAdmin: convenient for small to medium databases.
  • mysqldump CLI: better for big databases and automation.
# Full backup (all databases)
mysqldump -u dbadmin -p --all-databases --routines --triggers --single-transaction > /backups/all.sql

# Single database with compression
mysqldump -u dbadmin -p mydb --single-transaction | gzip > /backups/mydb-$(date +%F).sql.gz

Troubleshooting phpMyAdmin on Linux

403 Forbidden or 404 Not Found

  • Check Apache alias or Nginx alias and path.
  • Ensure your IP is allowed in Apache/Nginx config or Basic Auth is correct.
  • Reload the web server after changes.

Token Mismatch or Login Loop

  • Set a proper Blowfish secret in config.inc.php.
  • Verify session save path is writable by PHP.
  • Clear browser cookies for your domain.

Import Fails: File Too Large

Increase PHP and web server limits, then reload services.

# PHP (Apache SAPI example - adjust path/version)
sudo nano /etc/php/8.2/apache2/php.ini
upload_max_filesize = 512M
post_max_size = 512M
memory_limit = 1G
max_execution_time = 600

# Nginx (set high client body size)
sudo nano /etc/nginx/nginx.conf
http {
    client_max_body_size 512M;
}
sudo systemctl reload apache2 || sudo systemctl reload httpd
sudo systemctl reload nginx
sudo systemctl reload php8.2-fpm

Missing PHP Extensions (mbstring, zip, gd, xml)

  • Install missing extensions via apt/dnf and reload PHP-FPM/Apache.
  • Verify with php -m and phpinfo if needed.

Best Practices: Harden, Monitor, Automate

  • Rotate MySQL user passwords regularly and avoid root logins in phpMyAdmin.
  • Set fail2ban rules for Apache/Nginx to block brute-force attempts.
  • Schedule automated backups with cron and offsite storage.
  • Keep OS, PHP, and phpMyAdmin updated to patch vulnerabilities.
# Nightly database backup cron (example for root's crontab)
sudo crontab -e

0 2 * * * mysqldump -u dbadmin -p'Super_Strong_Passw0rd!' --all-databases \
--single-transaction --routines --triggers | gzip > /backups/all-$(date +\%F).sql.gz

phpMyAdmin vs CLI: Which Should You Use?

  • Use phpMyAdmin when you want a quick, visual way to manage schemas, users, and small imports/exports.
  • Use the MySQL CLI and automation (mysqldump, mysqlpump) for big data, migrations, or scripted deployments.
  • For production, keep phpMyAdmin behind strict access controls or expose it only via VPN/jump host.

Running phpMyAdmin on YouStable Servers

Hosting on YouStable makes this easier. Our Linux VPS and Cloud servers support LAMP/LEMP, free Let’s Encrypt SSL, firewalls, and optimized PHP stacks. Ask our team to pre-install and harden phpMyAdmin (custom path, IP allowlist, Basic Auth) so you can manage databases securely from day one.


FAQ’s

How do I access phpMyAdmin on a Linux server?

Install phpMyAdmin, configure your web server alias (e.g., /dbadmin), enable HTTPS, and browse to https://your-domain.com/dbadmin. Authenticate (Basic Auth if enabled) and log in with a MySQL user account—not the system user.

Is phpMyAdmin safe to use on a public server?

Yes, if it’s hardened: serve only over HTTPS, change the default path, restrict IPs, add Basic Auth, set a Blowfish secret, and keep PHP/phpMyAdmin updated. Consider VPN-only access for production.

How can I import a large database in phpMyAdmin?

Increase upload_max_filesize, post_max_size, and client_max_body_size (Nginx). For very large dumps, use CLI: mysql -u user -p dbname < dump.sql, which is faster and more reliable than the browser upload.

How do I reset the phpMyAdmin password?

phpMyAdmin uses MySQL credentials. Reset the MySQL user password in the database server: ALTER USER 'dbadmin'@'localhost' IDENTIFIED BY 'New_Strong_Pass!'; Then log in with the new password in phpMyAdmin.

How do I install phpMyAdmin on Ubuntu 22.04 quickly?

Run: sudo apt update && sudo apt install apache2 mariadb-server php php-mysql php-mbstring php-zip php-xml php-gd php-curl phpmyadmin. Enable the Apache conf, reload Apache, set a Blowfish secret, and browse to /dbadmin over HTTPS.

With these steps, you can confidently install, secure, and use phpMyAdmin on any Linux server—balancing convenience with robust security and operational best practices.

Share via:

Sanjeet Chauhan

Sanjeet Chauhan is a blogger & SEO expert, dedicated to helping websites grow organically. He shares practical strategies, actionable tips, and insights to boost traffic, improve rankings, & maximize online presence.

Leave a Comment

Your email address will not be published. Required fields are marked *

Scroll to Top