Managing databases from the command line is powerful, efficient, and wonderfully nerdy. But sometimes you do not want to memorize every CREATE USER, GRANT, and SHOW TABLES command before your morning coffee has fully activated. That is exactly where phpMyAdmin earns its place on an Ubuntu Server. It gives you a browser-based control panel for MySQL or MariaDB, making it easier to create databases, manage users, import SQL files, inspect tables, and troubleshoot application data without spelunking through a terminal for every tiny task.
This Addictive Tips-style guide walks through how to set up phpMyAdmin on Ubuntu Server using practical, production-minded steps. The focus is on Apache, MySQL or MariaDB, PHP, and basic hardening. The goal is not just to make phpMyAdmin load at /phpmyadmin. The goal is to install it cleanly, avoid the common login traps, and add enough security that your database dashboard is not standing outside with a neon sign saying, “Please brute-force me.”
The instructions below are suitable for modern Ubuntu Server releases such as Ubuntu 22.04 LTS and Ubuntu 24.04 LTS. Package names and versions may vary slightly depending on your server, but the workflow remains the same: update Ubuntu, install the web stack, install phpMyAdmin, configure database access, secure the interface, and verify everything works.
What Is phpMyAdmin?
phpMyAdmin is a free, open-source web application for managing MySQL and MariaDB databases. Instead of typing every database operation manually, you can use a graphical interface to browse tables, run SQL queries, import and export databases, change permissions, and review server settings.
It is especially useful for developers, website owners, small server administrators, WordPress users, and anyone who works with database-backed applications. If you manage a CMS, ecommerce site, forum, Laravel application, or custom PHP project, phpMyAdmin can save time during routine maintenance. It is not a replacement for understanding SQL, but it is a very helpful co-pilot.
Before You Install phpMyAdmin on Ubuntu Server
Before installing phpMyAdmin, your Ubuntu Server should have a working web server, PHP, and a database server. The classic setup is a LAMP stack: Linux, Apache, MySQL, and PHP. MariaDB can also be used instead of MySQL, since phpMyAdmin supports both.
Recommended prerequisites
- An Ubuntu Server with sudo access
- Apache installed and running
- MySQL or MariaDB installed and running
- PHP and required PHP extensions
- A firewall configured with SSH and web traffic allowed
- A domain name and HTTPS certificate for public servers
If you are working on a local lab server, you can test with an IP address. If this is a public-facing VPS, use a domain name, enable HTTPS, and apply the hardening steps later in this guide. A public phpMyAdmin page without protection is like leaving your house key under a doormat labeled “house key.” Convenient, yes. Wise, no.
Step 1: Update Ubuntu Packages
Start by updating the package list and upgrading installed packages. This helps avoid dependency issues and makes sure your server has current security patches.
After the upgrade finishes, reboot if the system asks for it, especially after kernel or core library updates.
Step 2: Install Apache, MySQL, and PHP
If your server does not already have a web stack, install Apache, MySQL, PHP, and common PHP extensions used by phpMyAdmin and many PHP applications.
On a MariaDB-based server, install MariaDB instead of MySQL:
Enable and start Apache and the database service:
For MariaDB, use:
Now confirm Apache is running:
If Apache is healthy, visiting your server IP address in a browser should show the default Apache page. It is not glamorous, but it is a good sign. Think of it as the server saying, “Yes, I am awake.”
Step 3: Secure MySQL or MariaDB
Before adding phpMyAdmin, secure the database server. Ubuntu database packages may ship with safer defaults than older releases, but running the security script is still a smart habit.
For MariaDB, depending on your version, you may also see or use:
The script may ask whether to remove anonymous users, disallow remote root login, remove the test database, and reload privilege tables. For most servers, answer yes to these security-focused prompts. If the tool asks about password validation, choose a policy that fits your environment. Strong passwords are boring right up until they save your weekend.
Step 4: Install phpMyAdmin on Ubuntu Server
Install phpMyAdmin from Ubuntu’s package repository:
During installation, you may see a configuration screen asking which web server should be configured automatically. Select apache2. Use the spacebar to mark it, then press Enter. If you simply press Enter without selecting Apache, phpMyAdmin may install but not become available through Apache automatically.
The installer may also ask whether to configure the database for phpMyAdmin with dbconfig-common. Choose Yes for a standard installation. You will be asked to create or confirm an application password for phpMyAdmin’s internal database user. Use a strong password and store it securely.
Step 5: Enable PHP mbstring and Restart Apache
The mbstring extension is commonly required for phpMyAdmin. Enable it and restart Apache:
Now test phpMyAdmin in a browser:
If you are using a domain name:
You should see the phpMyAdmin login page. Congratulations: the database cockpit is installed. Now do not fly it into a mountain by logging in as root without thinking through security.
Step 6: Create a Dedicated MySQL User for phpMyAdmin
On many Ubuntu systems, the MySQL root account uses socket authentication. That means the root database user can log in from the terminal with sudo mysql, but it may not be allowed to log in through phpMyAdmin using a password. This is normal, and it is often a good thing.
Instead of changing the root account, create a dedicated database user for phpMyAdmin. This is safer and cleaner. Log in to MySQL:
Create a new administrative user. Replace adminuser and StrongPasswordHere with your own values:
For a less powerful user, grant access only to a specific database:
Using separate users for separate applications makes your server easier to audit. It also reduces the blast radius if one password is exposed. In plain English: fewer things catch fire at once.
Step 7: Fix Apache Configuration If phpMyAdmin Does Not Load
If /phpmyadmin returns a 404 error, Apache may not have loaded the phpMyAdmin configuration. First, check whether the config file exists:
If you see a phpMyAdmin configuration file, enable it:
On some installations, the config file may be located at:
You can include it manually by editing Apache’s main config:
Add this line at the end:
Then restart Apache:
Step 8: Configure the Ubuntu Firewall
If UFW is enabled, allow SSH first so you do not lock yourself out. That is a rite of passage, but not one you need to experience today.
Allow Apache traffic:
Enable UFW if it is not already active:
Check the firewall status:
Apache Full allows both HTTP and HTTPS traffic. If your server is public, HTTPS should be treated as mandatory, not decorative.
Step 9: Enable HTTPS for phpMyAdmin
phpMyAdmin handles database credentials, so do not send logins over plain HTTP on a public network. Use Certbot and Let’s Encrypt to enable HTTPS for Apache.
Then run Certbot:
Follow the prompts, select your domain, and choose the option to redirect HTTP to HTTPS when offered. After Certbot finishes, test renewal:
Once HTTPS is active, access phpMyAdmin through your domain:
Step 10: Add an Extra Login Wall with Apache Basic Authentication
phpMyAdmin already has its own login screen, but adding Apache Basic Authentication creates a second gate. Attackers must pass the web server password before they even reach phpMyAdmin.
Install Apache utilities:
Create a password file:
Edit the phpMyAdmin Apache configuration:
Inside the <Directory /usr/share/phpmyadmin> block, add:
Save the file, check Apache syntax, and reload:
Now your browser should ask for a web server username and password before showing the phpMyAdmin login page. It is a small step with a big payoff.
Step 11: Change the Default phpMyAdmin URL
The default /phpmyadmin path is widely scanned by bots. Changing it is not a substitute for real security, but it can reduce noise in your logs.
Open the Apache configuration:
Find the alias line:
Change it to something less obvious:
Restart Apache:
Then access phpMyAdmin at:
Do not use a silly path like /secret or /not-phpmyadmin. Bots have seen more “clever” aliases than any of us have had hot lunches.
Step 12: Check phpMyAdmin Configuration Files
On Ubuntu, phpMyAdmin configuration is usually stored under:
The main configuration file is commonly:
This file may include settings for authentication type, server definitions, temporary directories, and the blowfish secret used for cookie authentication. If phpMyAdmin shows a warning about a missing or invalid blowfish secret, open the config file:
Look for:
Add a long random string:
Do not reuse your database password. This value is for internal cookie encryption, not for logging in.
Step 13: Troubleshoot Common phpMyAdmin Problems
Problem: phpMyAdmin shows a 404 page
Apache probably did not load the phpMyAdmin configuration. Run:
If that fails, manually include /etc/phpmyadmin/apache.conf in Apache’s configuration.
Problem: Cannot log in as root
This often happens because MySQL root uses socket authentication. Create a dedicated MySQL user instead of forcing root password login. It is cleaner and safer.
Problem: Missing PHP extension warning
Install and enable the missing extension. For example:
Problem: Upload size is too small
If importing SQL files fails because the file is too large, adjust PHP limits:
Update values such as:
Restart Apache afterward:
Best Practices for Using phpMyAdmin Safely
phpMyAdmin is useful, but it should be treated like a sensitive admin tool. Keep it updated through Ubuntu packages, use HTTPS, protect it with Basic Authentication, and avoid logging in with the database root account unless absolutely necessary.
For production servers, consider limiting access by IP address. If you always connect from a fixed office IP or VPN, Apache can restrict phpMyAdmin to that address. You can also place the interface behind a private VPN, which is often the strongest option.
Backups matter too. phpMyAdmin can export databases, but serious servers should have automated backups using tools such as mysqldump, mariadb-dump, snapshots, or managed backup systems. A manual export is handy; a scheduled backup is what saves you when someone accidentally drops a table named customers at 4:59 p.m. on Friday.
Example: A Practical phpMyAdmin Setup Workflow
Here is a compact real-world workflow for a new Ubuntu VPS:
- Install Apache, MySQL or MariaDB, PHP, and required extensions.
- Run the database security script.
- Install phpMyAdmin with
apt. - Select Apache during package configuration.
- Enable
mbstringand restart Apache. - Create a dedicated MySQL user for admin tasks.
- Enable UFW and allow SSH plus Apache Full.
- Install a Let’s Encrypt SSL certificate.
- Add Apache Basic Authentication.
- Change the default phpMyAdmin URL.
- Test login, database creation, imports, and exports.
This approach keeps the installation beginner-friendly while still respecting the fact that phpMyAdmin is a high-value target. Convenience is wonderful. Convenience plus security is better. Convenience without security is how server horror stories get written.
Experience Notes: Lessons from Setting up phpMyAdmin on Ubuntu Server
In real server work, installing phpMyAdmin is usually the easy part. The interesting part begins when you try to make it reliable, secure, and pleasant to use over time. One of the most common experiences is the “Why can’t root log in?” moment. Many new administrators assume something went wrong with phpMyAdmin, when the issue is actually MySQL authentication. Ubuntu often configures the root database account to authenticate through the local Unix socket. That is excellent for terminal administration, but it does not behave like a normal username-and-password login in a web interface. The fix is not panic. The fix is to create a dedicated user with the exact permissions needed.
Another practical lesson is that package configuration screens matter. During installation, the phpMyAdmin package may ask which web server to configure. It is easy to press Enter too quickly and accidentally skip Apache selection. The result is a perfectly installed phpMyAdmin package that Apache does not serve. When that happens, administrators often chase PHP errors that do not exist. The better troubleshooting path is simple: check Apache configuration, enable the phpMyAdmin conf file, reload Apache, and test again.
Security is where experience really changes the setup. On a private development VM, opening /phpmyadmin may be fine. On a public VPS, it is asking for attention from automated scanners. Server logs can fill with repeated requests to /phpmyadmin, /pma, /mysql, and every other common alias. Changing the URL does not make phpMyAdmin invisible, but it reduces low-effort noise. Adding Basic Authentication is even better because it blocks many automated attempts before they touch the application login screen.
HTTPS is another non-negotiable lesson. It is tempting to “just test quickly” over HTTP, but database credentials should never travel unencrypted across the internet. Certbot makes HTTPS much easier than it used to be, and once automatic renewal is working, there is little reason to avoid it. A secure phpMyAdmin setup should always include SSL, especially when accessed outside a trusted network.
Performance and usability also come up in day-to-day use. Large SQL imports may fail because PHP upload limits are too small, not because the database is broken. Increasing upload_max_filesize, post_max_size, and max_execution_time can solve many import problems. For very large databases, however, the command line is still the better tool. phpMyAdmin is excellent for inspection, quick edits, exports, and moderate imports, but giant production migrations are usually safer with terminal commands.
The best long-term habit is to treat phpMyAdmin as an administrative doorway, not a casual bookmark. Keep Ubuntu updated, avoid shared admin accounts, remove unused database users, monitor logs, and back up databases automatically. When configured with care, phpMyAdmin becomes a practical and time-saving dashboard. When installed lazily, it becomes a security headache wearing a friendly interface. The difference is only a few extra steps, and those steps are absolutely worth it.
Conclusion
Setting up phpMyAdmin on Ubuntu Server is straightforward once the pieces are in the right order. Install the LAMP stack, secure MySQL or MariaDB, install phpMyAdmin, enable the required PHP extensions, configure Apache, create a dedicated database user, and protect the interface with HTTPS and an extra authentication layer.
The biggest mistake is treating phpMyAdmin like a harmless convenience. It is convenient, yes, but it also controls your databases. Give it the same respect you would give SSH, your hosting dashboard, or the admin panel of your most important website. A well-configured phpMyAdmin installation can make database management faster, clearer, and less intimidating. Just lock the door before you enjoy the view.