Skip to content

Set Up phpMyAdmin on a Linux Server – Manage Your Databases via the Web Interface

Discover how to easily manage MySQL and MariaDB databases using phpMyAdmin’s web interface – for efficient database management

27 November 202610 min read33 Views0 helpful

Introduction

phpMyAdmin is a free, web-based tool for managing MySQL and MariaDB databases. From the interface in your browser, you can create databases and users, edit tables, run your own SQL queries, and back up databases by exporting them—all without manually typing SQL commands.

In this guide, we’ll show you two ways to install it: the easy way as a One-Click App, which makes phpMyAdmin available over HTTPS in just a few clicks, and a manual installation with Apache and PHP using the command line. Afterward, you’ll learn how to create databases and users, import and export data, and increase the upload limit for large SQL files.

When It Makes Sense to Use phpMyAdmin on Your Server

phpMyAdmin is not a database itself; it’s an interface for a database that is already running. This can be MariaDB or MySQL on the same server, for example, set up as described in How to Set Up MariaDB on a Linux Server or How to Set Up Databases on a Linux Server, or another database server that your server can access. phpMyAdmin is a good fit if:

  • You prefer managing databases with a mouse rather than the command line, for example, for WordPress, a forum, an online store, or a game server plugin’s database.
  • You want to import or export SQL files, for example, when moving a website or making a quick backup before an update.
  • Several people need to manage databases but should not have SSH access to the server.
  • You want to check tables or edit individual entries without having to memorize SQL commands.

phpMyAdmin is less suitable for very large databases with dumps in the gigabyte range: imports and exports run through the browser and are subject to upload and time limits, so the command line is more reliable for this. phpMyAdmin is not designed for PostgreSQL. If you use the ZAP Webspace One-Click App or a game server with a database, you don’t need to install it yourself, as explained in the note in the next section.

The Easy Way: phpMyAdmin as a One-Click App

With your server’s One-Click Apps, phpMyAdmin can be up and running in just a few minutes, without having to configure a web server and PHP yourself. The app does not include its own database: when you log in, you specify which MySQL or MariaDB server phpMyAdmin should connect to.

Requirements

Info: phpMyAdmin Is Often Already Included

The ZAP Webspace and ZAP Webspace + Mail apps already include phpMyAdmin. Open it using the phpMyAdmin link on the app card; see Web Hosting: Set Up a Website with ZAP Webspace. There’s also a separate access point for your game server’s database; see Game Server: PHPMyAdmin Access.

Install

  1. Open your VPS in the ZapX dashboard and go to the One-Click Apps tab.
  2. Search for “phpMyAdmin” in the App Catalog and click Install next to phpMyAdmin.
  3. Use a custom subdomain or zap.cloud is already selected, with a randomly generated name. Leave this option enabled or enter your own name: with a domain, phpMyAdmin is available over HTTPS, so your database passwords are encrypted in transit.
  4. Click Queue installation. After about a minute, the app will show as Online. You don’t need to fill in any other fields.

Log In

Open phpMyAdmin using the Access link on the app card. The login page asks for three details:

FieldWhat to enter
ServerThe IP address or hostname of your database server. If the database does not use port 3306, append the port, for example, 123.123.123.123:3307.
UsernameYour database username
PasswordThis user’s password

If you use the MariaDB One-Click App, enter your VPS’s IP address as the server. This also works when both apps are running on the same VPS. The username and password are in the MariaDB app settings (gear icon), under App environment > Automatically generated values (SERVICE_USER_MARIADB and SERVICE_PASSWORD_MARIADB).

After logging in, you’ll see your databases on the left. The tabs along the top include SQL for running your own queries, as well as Export and Import for backups and SQL files.

App Upload Limit

The app accepts files up to 8 MB when importing. To import larger SQL files, add a custom UPLOAD_LIMIT variable in the app settings (gear icon), under App environment, for example, with the value 256M. After saving, the app restarts and the import page displays the new maximum.

Security and Updates

  • The login page is accessible to anyone who knows its address. Use secure database passwords. If you only need phpMyAdmin occasionally, stop the app from its card and start it again when needed.
  • To install updates, go to the app settings (gear icon) > App update. Click Check for updates and, if a new version is available, click Apply update. Your databases are not affected because they are not stored in the app.
  • You don’t need to back up the app itself. Instead, back up your databases, for example, by exporting them as described below under “Import and Export.”

Manual Installation

The rest of this guide describes how to manually install phpMyAdmin with Apache and PHP using the command line, for example, on a dedicated server or a server that already has a web server running. The commands are for Debian and Ubuntu.

Requirements

  • A Linux server running Debian or Ubuntu with SSH access. If you’re not sure how to connect, see our guide First SSH Access.
  • A MariaDB or MySQL database running on this server or accessible from it. For instructions on installing MariaDB, see How to Set Up Databases on a Linux Server.
  • PHP version 7.2.5 or later. Current versions of Debian and Ubuntu include a suitable version. For more information about PHP, see our guide Install PHP.
  • For HTTPS: a domain or subdomain with an A record pointing to your server’s IP address (e.g. pma.example.com).

phpMyAdmin itself requires very little processing power. The following values are a good guideline for Apache, PHP, and phpMyAdmin; the database requires additional resources depending on its size:

HardwareMinimumRecommended
CPU1 vCPU core2 vCPU cores
RAM512 MB1 GB
Storage1 GB5 GB

Install the Web Server and PHP

First bring your system up to date, then install Apache, PHP, and the PHP extensions phpMyAdmin needs:

Code
sudo apt update -y
sudo apt upgrade -y
sudo apt install -y apache2 php libapache2-mod-php php-mysql php-mbstring php-zip php-gd php-xml php-curl unzip wget
Warning: Missing PHP Packages

If the required PHP packages are missing, phpMyAdmin’s PHP files cannot be processed and displayed correctly. Without php-mysql, phpMyAdmin cannot connect to the database.

Configure the Firewall

To make Apache accessible from the internet, open the ports for HTTP (80) and HTTPS (443) in the firewall. In this example, we use the UFW firewall, because Apache includes a dedicated profile for it. For more information about firewalls on Linux, see our guide Manage the Firewall.

Code
sudo apt install -y ufw
sudo ufw allow OpenSSH
sudo ufw allow in "Apache Full"
sudo ufw enable
sudo ufw status
Warning: Don’t Forget the SSH Rule

Make sure the SSH rule is in place before enabling UFW. Without it, you won’t be able to log in to the server over SSH if your connection is interrupted.

You don’t need to open database port 3306 for phpMyAdmin if the database is running on the same server: phpMyAdmin will connect locally.

Download phpMyAdmin

Use the cd /usr/share command to go to the directory where you want to install phpMyAdmin. Then download the latest version of phpMyAdmin and extract it:

Code
cd /usr/share
sudo wget https://www.phpmyadmin.net/downloads/phpMyAdmin-latest-all-languages.zip -O phpmyadmin.zip
sudo unzip -q phpmyadmin.zip

Now rename the extracted archive to a simpler name, delete the ZIP file, and set the required permissions:

Code
sudo mv phpMyAdmin-*-all-languages phpmyadmin
sudo rm phpmyadmin.zip
sudo chmod -R 0755 phpmyadmin

Configure Apache

Next, add phpMyAdmin to the web server configuration. Create a new configuration file with sudo nano /etc/apache2/conf-available/phpmyadmin.conf and add the following contents:

Code
Alias /phpmyadmin /usr/share/phpmyadmin

<Directory /usr/share/phpmyadmin>
    Options SymLinksIfOwnerMatch
    DirectoryIndex index.php
</Directory>

<Directory /usr/share/phpmyadmin/templates>
    Require all denied
</Directory>
<Directory /usr/share/phpmyadmin/libraries>
    Require all denied
</Directory>
<Directory /usr/share/phpmyadmin/setup/lib>
    Require all denied
</Directory>

Save the file with CTRL+X, confirm with Y, and press Enter. Then enable the configuration and reload Apache:

Code
sudo a2enconf phpmyadmin
sudo systemctl reload apache2

Configuration File and Temporary Directory

phpMyAdmin needs a temporary directory that the web server can write to, as well as a secret key for login cookies. Without the key, phpMyAdmin displays a warning after you log in saying that a temporary key has been generated. Create both as follows:

Code
sudo mkdir /usr/share/phpmyadmin/tmp/
sudo chown -R www-data:www-data /usr/share/phpmyadmin/tmp/
sudo cp /usr/share/phpmyadmin/config.sample.inc.php /usr/share/phpmyadmin/config.inc.php
sudo sed -i "s|^\$cfg\['blowfish_secret'\] = '';|\$cfg['blowfish_secret'] = '$(openssl rand -hex 16)';|" /usr/share/phpmyadmin/config.inc.php

The last command adds a random key with exactly 32 characters to the config.inc.php file. This file also contains all other phpMyAdmin settings, such as the database server (localhost by default).

First Visit

Open http://SERVER_IP/phpmyadmin in your browser. You’ll see the phpMyAdmin login page. Sign in with one of your database users.

Info: Root Login Fails

On Debian and Ubuntu, the root user can only log in to MariaDB from the command line by default (sudo mysql), not with a password. phpMyAdmin will then show “Access denied for user 'root'@'localhost'”. Instead, create a separate user with a password for phpMyAdmin, as described below under “Create a Database and User.”

After you log in, phpMyAdmin displays a notice at the bottom saying that the phpMyAdmin configuration storage is not fully configured. You only need it for additional features such as bookmarks or history; phpMyAdmin works without it.

HTTPS Access and Access Protection

Without HTTPS, your database username and password are sent over the internet unencrypted. First, add your domain to the Apache configuration: open /etc/apache2/sites-available/000-default.conf and add the line ServerName pma.example.com to the <VirtualHost *:80> block. Then use Certbot to get a free certificate from Let’s Encrypt:

Code
sudo systemctl reload apache2
sudo apt install -y certbot python3-certbot-apache
sudo certbot --apache -d pma.example.com

Certbot automatically updates the Apache configuration, redirects HTTP to HTTPS, and renews the certificate. You can then access phpMyAdmin at https://pma.example.com/phpmyadmin. Learn more in our guides Set Up Certbot and Create an SSL Certificate.

Automated attacks constantly scan the internet for phpMyAdmin, usually at the /phpmyadmin path. Protect the interface further using one of the following methods.

Additional password (Basic Auth): The browser will ask for a separate username and password before showing the login page. Create a user:

Code
sudo apt install -y apache2-utils
sudo htpasswd -c /etc/apache2/.htpasswd-phpmyadmin admin

Then add these four lines to the <Directory /usr/share/phpmyadmin> block in /etc/apache2/conf-available/phpmyadmin.conf and reload Apache with sudo systemctl reload apache2:

Code
    AuthType Basic
    AuthName "phpMyAdmin"
    AuthUserFile /etc/apache2/.htpasswd-phpmyadmin
    Require valid-user

Allow only specific IP addresses: If you have a static IP address, add the line Require ip 203.0.113.10 with your IP address to the same block instead. Everyone else will see a “Forbidden” message.

Tip: Additional Security Measures

Add $cfg['AllowRoot'] = false; to the end of config.inc.php to prevent logging in as root through phpMyAdmin. You can also choose a less obvious path than /phpmyadmin in the Alias. Find more tips for your server in Linux Security Tips.

Back Up Your Data

phpMyAdmin itself does not store any data. Your databases and the config.inc.php file are what matter. Back up individual databases in phpMyAdmin by clicking Export, as described in the next section. For regular or large backups, the command line is more reliable:

Code
mysqldump -u DB_USER -p --single-transaction DB_NAME > DB_NAME-$(date +%F).sql

Download your backups from the server regularly, for example, using SFTP. To restore a backup, import the file with mysql -u DB_USER -p DB_NAME < DB_NAME-DATE.sql.

Update phpMyAdmin

Update Apache and PHP packages with sudo apt update && sudo apt upgrade. You installed phpMyAdmin from a ZIP file, so you’ll need to install new versions manually. Rename the old installation, download the new version, and copy over your configuration:

Code
cd /usr/share
sudo mv phpmyadmin phpmyadmin-alt
sudo wget https://www.phpmyadmin.net/downloads/phpMyAdmin-latest-all-languages.zip -O phpmyadmin.zip
sudo unzip -q phpmyadmin.zip && sudo rm phpmyadmin.zip
sudo mv phpMyAdmin-*-all-languages phpmyadmin
sudo chmod -R 0755 phpmyadmin
sudo cp phpmyadmin-alt/config.inc.php phpmyadmin/
sudo mkdir phpmyadmin/tmp && sudo chown -R www-data:www-data phpmyadmin/tmp

Once you’ve confirmed that login works with the new version, remove the old directory with sudo rm -r /usr/share/phpmyadmin-alt. You can find the latest version and security notices at phpmyadmin.net.

Manage Databases with phpMyAdmin

These steps are the same for the One-Click App and the manual installation. phpMyAdmin displays the interface in your browser’s language; the terms below are from the German interface.

Create a Database and User

It’s best to create a separate database and user for each application, such as WordPress or a game server plugin. Here’s how to do both at once:

  1. Log in with a user who is allowed to create users, such as the user for your MariaDB app.
  2. Click User Accounts at the top, then click Add user account.
  3. Enter a username. Under Host name, select Local if only applications on the same server need access, or Any host (%) if other servers also need to connect.
  4. Set a secure password, for example, by clicking Generate password.
  5. Under Database for user account, select Create database with same name and grant all privileges.
  6. Click Go at the very bottom.

Leave the Global privileges section empty. The new user will then only be able to edit their own database. If your user doesn’t have permission to create users, as is the case with many hosting databases, you can only edit existing databases.

Import and Export

  • Export: Select the database on the left and click Export at the top. Choose the Quick export method and the SQL format to get a file containing all tables and data, which you can import later.
  • Import: Select the destination database on the left, click Import at the top, choose your .sql file (or a .zip or .gz file) under File to import, then click Go at the bottom. phpMyAdmin displays the maximum file size next to the file field.
Warning: Importing Can Overwrite Tables

If the SQL file contains tables that already exist in the destination database, the import will fail with an error or replace them, depending on whether the file contains DROP TABLE commands. Export the destination database before importing so you can restore it if needed.

Increase the Upload Limit

PHP determines the maximum file size you can import. The default for a manual installation is 2 MB. Change these values in Apache’s PHP configuration. Find the PHP version in the path by running php -v (e.g. 8.4 on Debian 13 or 8.3 on Ubuntu 24.04):

Code
sudo nano /etc/php/8.4/apache2/php.ini

Set these two values, then reload Apache with sudo systemctl reload apache2:

Code
upload_max_filesize = 256M
post_max_size = 256M

For the One-Click App, increase the limit by setting the UPLOAD_LIMIT variable, as described above under “App Upload Limit.”

What phpMyAdmin Can’t Do

  • It doesn’t include its own database: phpMyAdmin only manages MySQL and MariaDB servers that are already running. It does not support PostgreSQL or other databases.
  • Very large dumps: Files of several hundred MB often fail in the browser because of time or memory limits. Import them from the command line with mysql -u DB_USER -p DB_NAME < dump.sql.
  • It cannot exceed the database user’s privileges: phpMyAdmin can only do what the logged-in user is allowed to do in the database.

Conclusion

You’ve installed phpMyAdmin on your Linux server, secured it with HTTPS and additional access protection, and learned how to create databases and users, import and export data, and increase the upload limit. For instructions on setting up MariaDB itself, see How to Set Up MariaDB on a Linux Server.

Prefer not to use the command line? Choose the easy One-Click App method described above under “The Easy Way: phpMyAdmin as a One-Click App.”

Free tools

Related tools for servers and developers

View all

FAQ

Frequently asked questions

The One-Click App is the fastest option: it includes a web server and PHP, makes phpMyAdmin available over HTTPS when you use a domain, and lets you install updates from the dashboard. Manual installation with Apache and PHP is a good choice if your server already runs a web server, you don’t use One-Click Apps, or you want to control every setting, such as adding password protection or restricting access by IP address.
For the One-Click App, enter the IP address or hostname of your database server. If it uses a port other than 3306, add the port after a colon, for example, 123.123.123.123:3307. If you’re using the MariaDB One-Click App, enter your VPS’s IP address. You can find the username and password in the MariaDB app settings under App Environment. With a manual installation, phpMyAdmin connects to the database on the same server by default (localhost).
On Debian and Ubuntu, the MariaDB root user can only log in from the command line by default using sudo mysql, not with a password. phpMyAdmin will then show “Access denied for user 'root'@'localhost'”. Create a separate user with a password for phpMyAdmin and log in with that account.

Feedback

Was this article helpful?

Your feedback helps us prioritize and improve content.

0 of 0 people found this article helpful.

Personal support

Need more help than the guide provides?

Our ZAP-Hosting support team knows your product — briefly describe your issue and we'll help you personally.

Zappy knows this guide and answers you right in the chat.