Home → Articles → How to Install MySQL Database Server on Ubuntu 26.04

How to Install MySQL Database Server on Ubuntu 26.04

02 Apr, 2026

Introduction

MySQL is a free, open-source relational database management system that stores and organizes data in structured tables with rows and columns. Many web applications, content management systems like WordPress, and e-commerce platforms use MySQL as their backend database. The database server supports ACID (Atomicity, Consistency, Isolation, Durability) compliance, transactions, and replication, making it suitable for both small projects and large-scale enterprise applications.

This guide teaches you how to install MySQL on Ubuntu 26.04.

Prerequisites

Before you start:

Install MySQL Server

The MySQL package is available by default on the Ubuntu repositories. To install the package, follow these steps.

Run MySQL Secure Installation

MySQL includes a security script that helps you set a root password and remove insecure default settings. Run this script after the initial install to secure your database server.

Manage MySQL Service

MySQL runs as a system service on Ubuntu under the name mysql. You can manage this service using specific commands to start, stop, restart, and check the MySQL status. These commands ensure your MySQL installation runs smoothly and make maintenance easier on your system.

Check MySQL Service Status

console
$ sudo systemctl status mysql

Output:

● mysql.service - MySQL Community Server
     Loaded: loaded (/usr/lib/systemd/system/mysql.service; enabled; preset: enabled)
     Active: active (running) since Wed 2026-03-11 08:45:22 UTC; 2min 10s ago
    Process: 1245 ExecStartPre=/usr/share/mysql/mysql-systemd-start pre (code=exited, status=0/SUCCESS)
   Main PID: 1256 (mysqld)
     Status: "Server is operational"
      Tasks: 38 (limit: 2271)
     Memory: 365.2M (peak: 372.5M)
        CPU: 2.345s
     CGroup: /system.slice/mysql.service
             └─1256 /usr/sbin/mysqld

Press Ctrl + C.

Start MySQL Service

console
$ sudo systemctl start mysql

Stop MySQL Service

console
$ sudo systemctl stop mysql

Restart MySQL Service

console
$ sudo systemctl restart mysql

Enable MySQL to Start on Boot

console
$ sudo systemctl enable mysql

Output:

Synchronizing state of mysql.service with SysV service script with /usr/lib/systemd/systemd-sysv-install.
Executing: /usr/lib/systemd/systemd-sysv-install enable mysql

Configure MySQL to Accept Remote Connections (Optional)

By default, MySQL listens only on localhost. To allow remote clients to connect, you need to modify the MySQL configuration file and open the firewall port.

Create a Remote User

For security reasons, you should not use the root account for remote connections. Instead, create a dedicated user with specific privileges for remote access.

Configure Firewall for MySQL

If UFW (Uncomplicated Firewall) is active on your Ubuntu server, you need to allow traffic on port 3306, which is the default port MySQL uses.

Test the MySQL Database Server

In this section, you'll test your MySQL installation by logging into the database server, creating a sample database and table, inserting some data, and querying the table to ensure everything functions correctly. This process helps verify that your installation works as expected and that you can seamlessly perform basic database operations.

Your MySQL database server is working as expected.

Conclusion

In this guide, you have installed MySQL on Ubuntu 26.04 using apt, secured the database server with the mysql_secure_installation script, configured remote access, created a dedicated remote user, opened the firewall port, and created a sample database with tables and records. Now that you have MySQL running, consider integrating the database with a web application using PHP with MySQLi or PDO, or connect it with Python using the mysql-connector-python library to build data-driven applications.