phpMyAdmin is a free, open-source PHP application that provides a browser-based interface for managing MySQL and MariaDB servers. It lets you create and delete databases, manage user accounts and privileges, run SQL queries, and import or export data in formats including CSV, SQL, and JSON. All of this works without touching the MySQL command line.
This guide covers how to install phpMyAdmin on Ubuntu 18.04 with Apache and how to secure it with an extra layer of HTTP Basic Authentication. Before starting, make sure the LAMP stack (Linux, Apache, MySQL, PHP) is already installed and running on your server.
<strong>Prerequisite:</strong> You need sudo access and an existing LAMP installation.
Update the package list and install phpMyAdmin:
bashsudo apt update && sudo apt upgradesudo apt install phpmyadmin
The installer runs an interactive wizard with three prompts:
apache2, then press Enter. This automatically configures Apache to serve phpMyAdmin at /phpmyadmindbconfig-common, select Yes. This creates phpMyAdmin’s internal configuration database without manual SQL stepsAfter the wizard completes, restart Apache to load the phpMyAdmin configuration:
bashsudo systemctl restart apache2
In Ubuntu systems running MySQL 5.7 and later, the root account uses the auth_socket authentication plugin by default. This plugin validates connections through the Unix socket, not a password. You cannot log in to phpMyAdmin as root using a password.
Instead, create a dedicated MySQL admin user with mysql_native_password authentication:
bashsudo mysql
sqlCREATE USER 'padmin'@'localhost' IDENTIFIED BY 'super-strong-password';GRANT ALL PRIVILEGES ON *.* TO 'padmin'@'localhost' WITH GRANT OPTION;
WITH GRANT OPTION gives this user the ability to create other MySQL users and grant them permissions — the same capability the root account has. Use a strong password and note it down.
Open https://your_domain_or_ip/phpmyadmin in a browser and log in with the padmin credentials you just created. The phpMyAdmin dashboard shows your databases in the left sidebar and server information in the main panel. Use the interface to create databases, run queries, import and export data, and manage user accounts.
The /phpmyadmin URL is publicly known and frequently targeted by automated scanners. Adding HTTP Basic Auth creates a second authentication barrier before the phpMyAdmin login form appears.
Create the Basic Auth password file using Apache’s htpasswd tool. The -c flag creates the file. To add more users later, run the same command without -c:
bashsudo htpasswd -c /etc/phpmyadmin/.htpasswd padmin
Edit the Apache phpMyAdmin configuration at /etc/apache2/conf-available/phpmyadmin.conf. Inside the <Directory /usr/share/phpmyadmin> block, add these directives:
apacheAuthType basicAuthName "Authentication Required"AuthUserFile /etc/phpmyadmin/.htpasswdRequire valid-user
Restart Apache to apply the changes:
bashsudo systemctl restart apache2
Accessing /phpmyadmin now prompts for the Basic Auth credentials first, then the phpMyAdmin MySQL login form. Anyone without the Basic Auth password cannot reach the phpMyAdmin login page at all.
One more security step. Rename the default /phpmyadmin alias to something less predictable, such as /dbadmin or a random string. Change the Alias directive in /etc/apache2/conf-available/phpmyadmin.conf and restart Apache. This significantly reduces automated scan traffic targeting your admin panel.
phpMyAdmin is now installed and secured on your Ubuntu 18.04 server. Use it to manage databases, create users, run queries, and handle data imports and exports through the browser. Leave a comment below if you run into any issues.
Zabbix is a mature open-source infrastructure monitoring platform that collects metrics from network devices, servers, virtual…
Gradle is a powerful open-source build automation tool used primarily for Java, Kotlin, Groovy, and Android…
TeamViewer is a proprietary cross-platform remote access application for remote control, desktop sharing, file transfer, and online meetings. It is one of the most widely used remote support tools in the world, available for Windows, macOS, Linux, iOS, and Android. TeamViewer is not included in the Ubuntu repositories because it is proprietary software. This guide covers how to install TeamViewer on Ubuntu 18.04 using the official .deb package. The same steps apply to Ubuntu 16.04, Debian, Linux Mint, and Elementary OS. <strong>Prerequisite:</strong> You need sudo access. Install TeamViewer on Ubuntu: Download the .deb Package Download the official TeamViewer .deb package. The _amd64.deb suffix indicates this package is for 64-bit x86-64 systems. For ARM-based machines, download the appropriate package from the TeamViewer Linux downloads page: bashwget https://download.teamviewer.com/download/linux/teamviewer_amd64.deb Install the package using apt. The ./ prefix tells apt this is a local file path, not a package name from the repositories:…
Nagios is one of the most widely used open-source infrastructure monitoring systems in the world. It…
Laravel is an open-source PHP web application framework built around an expressive, developer-friendly syntax. It is…
Kodi (formerly XBMC, short for Xbox Media Center) is a free, open-source, cross-platform media player and…