DEV Community

Cover image for How to Install MySQL and phpMyAdmin on Ubuntu (with Monitoring)
Alexander Neitzel
Alexander Neitzel

Posted on Originally published at garmingo.com

How to Install MySQL and phpMyAdmin on Ubuntu (with Monitoring)

MySQL and phpMyAdmin are the go-to combo for managing databases in web projects.

Whether you're building something serious or just tinkering, self-hosting your own stack gives you full control โ€” and itโ€™s easier than you think.

In this guide, Iโ€™ll show you how to:

  1. Install MySQL on Ubuntu
  2. Secure your database
  3. Set up phpMyAdmin
  4. Add real uptime monitoring โ€” so you know when something breaks

๐Ÿงฐ What Youโ€™ll Need

  • A fresh Ubuntu 22.04 server
  • sudo/root access
  • A domain name (optional, but recommended for phpMyAdmin)
  • 10โ€“15 minutes

โšก Step 1: Install MySQL Server

Update your server:

sudo apt update && sudo apt upgrade -y
Enter fullscreen mode Exit fullscreen mode

Install MySQL:

sudo apt install mysql-server -y
Enter fullscreen mode Exit fullscreen mode

Secure your installation:

sudo mysql_secure_installation
Enter fullscreen mode Exit fullscreen mode

Answer the prompts to remove anonymous users, disallow remote root login, etc.


๐Ÿ” Step 2: Create a MySQL User and Database

Log in to MySQL:

sudo mysql
Enter fullscreen mode Exit fullscreen mode

Then run:

CREATE DATABASE myapp_db;  
CREATE USER 'myuser'@'localhost' IDENTIFIED BY 'strongpassword';  
GRANT ALL PRIVILEGES ON myapp_db.* TO 'myuser'@'localhost';  
FLUSH PRIVILEGES;  
EXIT;
Enter fullscreen mode Exit fullscreen mode

๐ŸŒ Step 3: Install phpMyAdmin

Install required dependencies:

sudo apt install phpmyadmin php-mbstring php-zip php-gd php-json php-curl -y
Enter fullscreen mode Exit fullscreen mode

During setup:

  • Choose Apache (if prompted)
  • Configure a MySQL application password

Enable extensions:

sudo phpenmod mbstring  
sudo systemctl restart apache2
Enter fullscreen mode Exit fullscreen mode

Now access it at:

http://your-server-ip/phpmyadmin


๐ŸŒ Step 4: (Optional) Set Up a Domain for phpMyAdmin

Point a subdomain (like db.yourdomain.com) to your serverโ€™s IP.

Then set up a reverse proxy (e.g. with NGINX) and secure it with HTTPS via Letโ€™s Encrypt.


๐Ÿ›ก๏ธ Step 5: Secure phpMyAdmin Access

Protect access by:

  • Adding .htpasswd authentication
  • Restricting by IP
  • Moving it to a non-obvious path (/mydbadmin)

โœ… Step 6: Monitor Your MySQL Stack with Garmingo Status

Congrats โ€” your DB stack is running.

But what happens if it goes down?

๐Ÿ’ก Donโ€™t wait to find out the hard way. Add uptime monitoring now:

  • Create a free Garmingo Status account
  • Add a monitor for:
    • http(s)://yourdomain.com/phpmyadmin
    • Port 3306 (MySQL)
    • Your public IP (Ping monitor)

Youโ€™ll get:

  • Real-time alerts (Slack, Email, Telegram, etc.)
  • Public or private status pages
  • Downtime logs & SLA tracking
  • PDF uptime reports

๐Ÿ†“ 100% free plan. No credit card. Instant peace of mind.

๐Ÿ‘‰ Get started here


๐Ÿง˜ TL;DR

  • โœ… Install MySQL
  • โœ… Set up phpMyAdmin
  • ๐Ÿ”’ Secure everything
  • ๐Ÿ“ˆ Monitor it with Garmingo Status

If your database goes down and no one's watchingโ€ฆ is it really running?

๐Ÿ‘‰ Start monitoring your stack today

Top comments (0)