This guide covers database server Ubuntu step by step, with every setting in the order you will use it. MySQL and MariaDB are the default database servers on Linux, powering everything from WordPress to enterprise apps. This guide installs and hardens one on Ubuntu Server — a natural companion to the Ubuntu web server and a sibling of the Windows Server database guide.

dns LAB TOPOLOGY & PREREQUISITES
# example values used while writing and testing this guide
LAB VM
UBUNTU BUILD
VALIDATION
01constructionStep 1: Install the Server
Update the package index and install MySQL:
sudo apt update && sudo apt install mysql-server -y
(MariaDB is a drop-in alternative: sudo apt install mariadb-server.) The service starts automatically and is enabled at boot. Check it with systemctl status mysql.
02downloadStep 2: Secure the Installation
Run the included hardening wizard:
sudo mysql_secure_installation
It walks you through setting a root password validation policy, removing anonymous users, disabling remote root login and dropping the test database. On Ubuntu, administrative login from the shell uses sudo mysql (socket authentication); set a root password for remote admin as needed.
03usbStep 3: Create a Database and Application User
Inside the client (sudo mysql):
CREATE DATABASE appdb CHARACTER SET utf8mb4;
CREATE USER 'appuser'@'localhost' IDENTIFIED BY 'StrongPass!';
GRANT ALL ON appdb.* TO 'appuser'@'localhost';
For a web server on another machine, create the user with its host instead: 'appuser'@'192.168.1.%'.
04terminalStep 4: Allow Remote Clients and Test
If clients connect over the network: set MySQL to listen on the server’s IP (edit bind-address in the configuration under /etc/mysql, then restart the service), allow port 3306 in the firewall (sudo ufw allow 3306), and test from the client with mysql -h db01 -u appuser -p.
Back up databases regularly with mysqldump, and when you move to the cloud, managed equivalents like AWS RDS automate all of this for you.
Related Content
Explore the Next Track
You finished this track, so pick the next one from the homepage hub.